You can use spatial functions to process spatial data.
The implementation of these spatial functions follows the OGC Simple Features for SQL
specification and parts of the ISO SQL/MM Part 3: Spatial standard.
The spatial functions fall into the following categories:
Construction of geometries from data exchange formats or coordinate data
The following functions create a geometry of the ST_Geometry type or one of its subtypes from
coordinate data, or from a well-known text (WKT), well-known binary (WKB), ESRI shape, or Geography
Markup Language (GML) data exchange format:
Table 1. Spatial functions that construct geometries from data exchange formats or coordinate
data
Function use |
Function name |
Construct any geometry from a WKT, WKB, ESRI
shape, or GML objectConstruct any geometry from a WKT, WKB, ESRI
shape, GML object, or GeoJSON |
|
Construct any geometry from a WKT object |
|
Construct any geometry from a WKT or GML
objectConstruct any geometry from a WKT, GeoJSON, or GML
object |
|
Construct any geometry from a WKB object |
|
Construct a specific geometry from a WKT, WKB,
ESRI shape, or GML objectConstruct a specific geometry from a WKT,
WKB, ESRI shape, GML object, or GeoJSON |
|
Construct a specific geometry from coordinates |
|
Construct a specific geometry from a WKT or GML
objectConstruct a specific geometry from a WKT, GeoJSON, or GML
object |
|
Construct a specific geometry from a WKB object |
|
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 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 WKT object |
|
Convert a geometry into a WKB object |
|
Convert a geometry into an ESRI shape object |
|
Convert a geometry into a GML object |
|
Convert a geometry into a GeoJSON object |
|
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 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 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 from a curve |
|
Create a new geometry from a curve or multi-curve |
|
Create a new geometry by combining multiple geometries |
|
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 functions that retrieve 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 geometries
The following functions return information about geometric properties such as coordinates,
measures, and boundaries:
Table 6. Spatial functions that return information about properties of geometries
Function use |
Function name |
Return information about spatial reference systems |
|
Return information to indicate whether geometry properties are identical |
|
Return information about geometry types |
|
Return information about 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 |
|