Skip to main content

Supported Spatial Operations

GeoETL provides 39 PostGIS-compatible spatial SQL functions powered by the GEOS library. These functions enable geometry manipulation, spatial analysis, and data transformation within your SQL queries.

Quick Reference

CategoryFunctionsDescription
Construction4Create geometries from various input formats
Measurement3Measure distance, area, and length
Predicate10Test spatial relationships
Validator5Validate geometry properties
Generator8Generate new geometries
Set Operations4Combine geometries using set theory
Accessor6Extract geometry properties

All Functions

Construction Functions

FunctionDescription
ST_GeomFromTextParse WKT string to geometry
ST_GeomFromWKBValidate WKB binary data
ST_PointCreate point from X, Y coordinates
ST_MakePointAlias for ST_Point

Measurement Functions

FunctionDescription
ST_DistanceCalculate minimum distance between geometries
ST_AreaCalculate area of a geometry
ST_LengthCalculate length/perimeter of a geometry

Predicate Functions

FunctionDescription
ST_IntersectsTest if two geometries intersect
ST_ContainsTest if geometry A contains geometry B
ST_WithinTest if geometry A is within geometry B
ST_OverlapsTest if two geometries overlap
ST_TouchesTest if geometries touch at boundaries
ST_CrossesTest if geometries cross each other
ST_DisjointTest if geometries are disjoint
ST_EqualsTest if geometries are spatially equal
ST_CoversTest if geometry A covers geometry B
ST_CoveredByTest if geometry A is covered by geometry B

Validator Functions

FunctionDescription
ST_IsValidTest if geometry is valid (OGC rules)
ST_IsEmptyTest if geometry is empty
ST_IsSimpleTest if geometry is simple
ST_IsClosedTest if geometry is closed
ST_IsRingTest if geometry is a ring

Generator Functions

FunctionDescription
ST_BufferCreate buffer polygon around geometry
ST_CentroidCalculate centroid point
ST_EnvelopeCompute bounding box
ST_ConvexHullCompute convex hull
ST_BoundaryCompute geometry boundary
ST_PointOnSurfaceGet point guaranteed on surface
ST_SimplifyDouglas-Peucker simplification
ST_SimplifyPreserveTopologyTopology-preserving simplification

Set Operation Functions

FunctionDescription
ST_UnionCombine two geometries
ST_IntersectionIntersection of two geometries
ST_DifferenceDifference of geometries (A - B)
ST_SymDifferenceSymmetric difference (XOR)

Accessor Functions

FunctionDescription
ST_XGet X coordinate of a Point
ST_YGet Y coordinate of a Point
ST_NumPointsCount of points in geometry
ST_NumGeometriesCount of geometries in collection
ST_GeometryTypeGet geometry type as string
ST_DimensionGet topological dimension

Usage Examples

Basic Geometry Creation

SELECT ST_Point(longitude, latitude) as geom FROM locations;
SELECT ST_GeomFromText('POLYGON((0 0, 4 0, 4 4, 0 4, 0 0))') as polygon;

Spatial Analysis

-- Find all buildings within 100 meters of a point
SELECT * FROM buildings
WHERE ST_Distance(geom, ST_Point(-122.4, 37.8)) < 100;

-- Calculate total area by category
SELECT category, SUM(ST_Area(geom)) as total_area
FROM parcels
GROUP BY category;

Geometry Transformation

-- Create 50-meter buffer zones
SELECT id, ST_Buffer(geom, 50) as buffer FROM features;

-- Simplify complex geometries
SELECT id, ST_Simplify(geom, 0.001) as simplified FROM coastlines;

Spatial Filtering

-- Find intersecting features
SELECT a.id, b.id
FROM layer_a a, layer_b b
WHERE ST_Intersects(a.geom, b.geom);

-- Filter by containment
SELECT * FROM points
WHERE ST_Within(geom, (SELECT geom FROM boundaries WHERE name = 'Region A'));

Notes

  • All functions use the GEOS library for computational geometry
  • Input geometries can be in GeoArrow Point, WKB, or mixed geometry formats
  • Output geometries are returned as WKB with geoarrow.wkb metadata
  • NULL inputs return NULL outputs (SQL standard behavior)
  • Functions are case-insensitive in SQL queries