Installing and setting up DB2 Spatial Extender provides the following main features and components:
- Spatial datatypes
- A set of datatypes that can be used to define table columns that will contain spatial data. This includes ST_Point, ST_Linestring, and ST_Polygon for atomic spatial values. This also includes ST_MultiPoint, ST_MultiLinestring, and ST_MultiPolygon for homogeneous collections of spatial values.
- Spatial functions and predicates
- A large number of SQL UDFs to create spatial values, return information about spatial values, identify spatial relationships, and perform operations on spatial values. These spatial UDFs can be incorporated into SQL queries, which exploit all the capabilities of the SQL language.
- Spatial index
- A spatial index mechanism is provided to support the two-dimensional nature of spatial data. Tools are available to help specify a spatial index.
- Spatial command line processor (CLP) - db2se
db2seCLP provides a convenient command line interface to spatial stored procedures for operations such as spatially enabling a database and importing or exporting spatial data.
See Resources for more details about the Spatial Extender in the DB2 Infocenter.
Spatial data is typically represented by tuples of coordinate values, most often x, y, although support is provided for z and m coordinates as well. This tutorial considers data with only x and y coordinate values. It will also consider data that uses only latitude and longitude values in degrees as decimal values. Note that when working with latitude and longitude, longitude corresponds to x and latitude corresponds to y.
In order to correctly perform spatial operations, every spatial value must have a coordinate system associated with it that describes the relationship of the coordinate values to a position on the earth's surface. Although Spatial Extender provides over 3000 different pre-defined coordinate systems, this tutorial addresses only the two most commonly used: NAD83 for coordinates in North America and WGS84 for worldwide coordinates. Note that most GPS devices report coordinates using WGS84.
In order to efficiently store and process spatial data, Spatial Extender represents coordinates internally as 64-bit integers. Spatial Extender manages this through the use of a spatial reference system (SRS) that specifies offsets and a scale factor used to convert the user representation in a DOUBLE value back and forth from the internal representation. Each SRS also has a coordinate system associated with it. It is actually the SRS that is associated with each spatial value. An SRS may be referred to by either its 128-character-value name (referred to as srsName or SRS_NAME) or its 32-bit-integer identifier (referred to as srid or SRS_ID). The srid is used in SQL statements, and the srsName is used with the db2se CLP, most often when importing spatial data.
Spatial Extender provides the SRS named NAD83_SRS_1 with srid 1 for data using the NAD83 coordinate system. Spatial Extender provides the SRS name WGS84_SRS_1003 with srid 1003 for data using the WGS84 coordinate system. Refer to the documentation in the DB2 Infocenter if you need to work with a different coordinate system.