Spatial functions

Use spatial functions to program your applications. Learn about the function usage and the factors that are common to all or most spatial functions.

Db2® Spatial Extender follows the OGC Simple Features for SQL specification and the ISO SQL/MM Part 3: Spatial standard in the implementation of spatial functions.

Construction of geometries from data exchange formats

The following functions create a geometry of the ST_Geometry type or one of its subtypes from a data exchange format:
Table 1. Spatial Extender functions that construct geometries from data exchange formats
Function use Function name
Construct any geometry from a well-known text, a well-known binary, an ESRI shape, or a Geographic Markup Language (GML) format
Construct a specific geometry from a well-known text, a well-known binary, an ESRI shape, or a GML format
Construct a specific geometry from coordinates
Construct any geometry from a well-known text representation
Construct a specific geometry from a well-known text representation
Construct any geometry from a well-known binary representation
Construct a specific geometry from a well-known binary representation

For more information about supported data exchange formats, see Supported data formats

Conversion of a geometry into a data exchange format

The following functions convert a geometry of the ST_Geometry type or one of its subtypes into a data exchange format:
Table 2. Spatial Extender functions that convert a geometry of the ST_Geometry type or one of its subtypes into a data exchange format
Function use Function name
Convert a geometry into a well-known text representation
Convert a geometry into a well-known binary representation
Convert a geometry into an ESRI shape format
Convert a geometry into a GML format

For more information about supported data exchange formats, see Supported data formats

Comparison of geometries and discovery of relations between geometries

These spatial functions return information that is the result of a comparison between geometries, between definitions of coordinate systems, or between spatial reference systems. They return information about ways in which geographic features relate to one another or compare with one another.
Table 3. Spatial Extender functions that compare geometries and find relations between geometries
Function use Function name
Check whether two items geometries are identical
Determine the distance between geometries
Determine whether geometries intersect
Determine whether a geometry contains another one
Compare geometry envelopes
Compare two geometries and determine whether they meet the conditions of the DE-9IM pattern matrix string

Construction of new geometries from existing geometries

The following functions modify properties of a geometry of type ST_Geometry or one of its subtypes to construct a new geometry:
Table 4. Spatial Extender functions that construct new geometries from existing geometries
Function use Function name
Convert geometries between coordinate systems
Create modified forms of existing geometries
Create new geometries with different space configurations
Construct envelopes and boundaries
Create new geometry based on existing geometry measures
Create a new geometry by combining multiple geometries
Create a new geometry from a curve
Create a new geometry from a curve or multi-curve
Convert geometries of a supertype into corresponding geometries of a subtype.

Retrieval of geometries that are part of a geometry

The following functions that obtain specified geometries from collections of geometry objects:
Table 5. Spatial Extender functions that obtain a geometry that is part of a geometry
Function use Function name
Obtain a geometry from within an existing geometry by using an index
Obtain points from a curve

Information about spatial indexes and geometries

The following functions return information about spatial indexes and geometric properties such as coordinates, measures, and boundaries:
Table 6. Spatial Extender functions that return information about spatial indexes and properties of geometries
Function use Function name
Return information about spatial indexes
Return information about spatial reference systems
Return information to indicate whether geometry properties are identical
Return information about geometry type
Return information about a geometry dimensions
Return information about boundaries, envelopes, rings, and geometries in a geometry
Return information to indicate whether envelopes or bounding boxes intersect
Return information about coordinates and measures
Return information to indicate whether a geometry is closed, empty, or simple