ST_ prefix. These functions enable you to create, manipulate, measure, and analyze spatial data.
Function Categories
Constructors
Create geospatial objects from coordinates, WKT, WKB, and GeoJSON
Measurements
Calculate distances, areas, and geometric properties
Relationships
Test spatial relationships like containment and intersection
Outputs
Convert geospatial objects to various formats
Conversions
Transform between geometry and geography types
Aggregations
Combine multiple geometries into collections
Constructors
Functions for creating geospatial objects from various input formats.ST_Point
Creates a point geometry from X,Y coordinates.ST_GeomFromText
Creates geometry from Well-Known Text (WKT) representation.ST_GeomFromWKB
Creates geometry from Well-Known Binary (WKB) representation.ST_Polygon
Creates a polygon geometry from WKT representation.ST_GeogFromText
Creates geography from Well-Known Text with spherical calculations.ST_GeogFromWKB
Creates geography from Well-Known Binary representation.ST_GeomFromGeoJson
Creates geometry from GeoJSON string.ST_GeogFromGeoJson
Creates geography from GeoJSON string.Measurements
Functions for calculating spatial measurements and properties.ST_Distance
Calculates distance between two geometries or geographies.For Geography: Returns great-circle distance in meters Examples:
ST_Area
Calculates the area of a polygon geometry or geography.For Geography: Returns area in square meters using spherical model Examples:
ST_GeometryType
Returns the type of a geometry or geography as a string.Relationships
Functions for testing spatial relationships between geometries.ST_Contains
Tests if the first geometry completely contains the second.ST_Within
Tests if the first geometry is completely within the second.ST_Equals
Tests if two geometries or geographies represent the same geometry.Outputs
Functions for converting geospatial objects to various output formats.ST_AsText
Converts geometry or geography to Well-Known Text (WKT).ST_AsBinary
Converts geometry or geography to Well-Known Binary (WKB).ST_AsGeoJson
Converts geometry or geography to GeoJSON format.Conversions
Functions for converting between geometry and geography types.toSphericalGeography
Converts a Geometry object to spherical geography.toGeometry
Converts a spherical geography object to geometry.Aggregations
Functions for combining multiple geometries.ST_Union
Combines multiple geometries into a single MULTI geometry.Function Usage with Indexes
Functions that Use H3 Index
These functions automatically leverage geospatial indexes when properly configured:
Index-Optimized Query Patterns:
Checking Index Usage
UseEXPLAIN PLAN FOR to verify index usage:
FILTER_H3_INDEX- ST_Distance queries using indexINCLUSION_FILTER_H3_INDEX- ST_Within/ST_Contains queries using index
Best Practices
Performance Tips
- Use geography types for global applications requiring meter-based distances
- Use geometry types for regional analysis where coordinate units are acceptable
- Index your spatial columns with appropriate H3 resolutions
- Structure queries to leverage indexes (proper argument order)

