Skip to main content

GeoETL v0.7.0: Complete Spatial SQL Toolkit with 29 New Functions

· 4 min read
Yogesh
GeoETL Maintainer

TL;DR: GeoETL v0.7.0 adds 29 new spatial SQL functions including predicates (ST_Intersects, ST_Contains), geometry generators (ST_Buffer, ST_ConvexHull), validators (ST_IsValid), and accessors (ST_X, ST_Y).

What's New

v0.6.0 introduced area and length calculations. v0.7.0 delivers a complete spatial SQL toolkit with 29 new functions across 6 categories, bringing the total to 36 spatial UDFs.

Spatial Predicates: Query by Location

Test spatial relationships between geometries with 10 new binary predicates:

FunctionDescription
ST_IntersectsTrue if geometries share any space
ST_ContainsTrue if first geometry contains second
ST_WithinTrue if first geometry is within second
ST_OverlapsTrue if geometries overlap but neither contains the other
ST_TouchesTrue if geometries touch at boundary only
ST_CrossesTrue if geometries cross each other
ST_DisjointTrue if geometries share no space
ST_EqualsTrue if geometries are spatially equal
ST_CoversTrue if first geometry covers second
ST_CoveredByTrue if first geometry is covered by second

Example: Find Buildings in Flood Zones

geoetl-cli convert \
-i buildings.geojson \
-o at_risk.geojson \
--input-driver GeoJSON \
--output-driver GeoJSON \
--sql "SELECT b.* FROM buildings b, flood_zones f
WHERE ST_Intersects(b.geometry, f.geometry)"

Example: Points Within Polygon

geoetl-cli convert \
-i cities.geojson \
-o cities_in_state.csv \
--input-driver GeoJSON \
--output-driver CSV \
--sql "SELECT name, population
FROM cities
WHERE ST_Within(geometry, ST_GeomFromText('POLYGON(...)'))"

Geometry Generators: Create New Shapes

Transform geometries with 6 new generator functions:

FunctionDescription
ST_Buffer(geom, distance)Create buffer around geometry
ST_EnvelopeBounding box of geometry
ST_ConvexHullConvex hull of geometry
ST_BoundaryBoundary of geometry
ST_PointOnSurfacePoint guaranteed to be on surface
ST_Simplify(geom, tolerance)Douglas-Peucker simplification

Example: Create Buffer Zones

geoetl-cli convert \
-i hospitals.geojson \
-o hospital_zones.geojson \
--input-driver GeoJSON \
--output-driver GeoJSON \
--sql "SELECT name, ST_Buffer(geometry, 1000) as geometry
FROM hospitals"

Example: Simplify Complex Polygons

geoetl-cli convert \
-i detailed_boundaries.geojson \
-o simplified.geojson \
--input-driver GeoJSON \
--output-driver GeoJSON \
--sql "SELECT name, ST_Simplify(geometry, 100) as geometry
FROM detailed_boundaries"

Set Operations: Combine Geometries

Perform geometric set operations with 4 functions:

FunctionDescription
ST_IntersectionShared area between geometries
ST_UnionCombined area of geometries
ST_DifferenceFirst geometry minus second
ST_SymDifferenceArea in either but not both

Example: Find Overlapping Areas

geoetl-cli convert \
-i parcels.geojson \
-o overlaps.geojson \
--input-driver GeoJSON \
--output-driver GeoJSON \
--sql "SELECT ST_Intersection(a.geometry, b.geometry) as geometry
FROM parcels a, zones b
WHERE ST_Intersects(a.geometry, b.geometry)"

Geometry Validators: Check Quality

Validate geometry quality with 5 new functions:

FunctionDescription
ST_IsValidTrue if geometry is valid
ST_IsEmptyTrue if geometry is empty
ST_IsSimpleTrue if geometry has no self-intersection
ST_IsClosedTrue if linestring is closed
ST_IsRingTrue if linestring is closed and simple

Example: Find Invalid Geometries

geoetl-cli convert \
-i parcels.geojson \
-o invalid_parcels.csv \
--input-driver GeoJSON \
--output-driver CSV \
--sql "SELECT parcel_id, ST_IsValid(geometry) as is_valid
FROM parcels
WHERE NOT ST_IsValid(geometry)"

Geometry Accessors: Extract Properties

Extract geometry properties with 6 new accessor functions:

FunctionDescription
ST_XX coordinate of point
ST_YY coordinate of point
ST_NumPointsCount of points in geometry
ST_NumGeometriesCount of geometries in collection
ST_GeometryTypeType name (Point, Polygon, etc.)
ST_DimensionTopological dimension (0, 1, or 2)

Example: Extract Coordinates

geoetl-cli convert \
-i cities.geojson \
-o coordinates.csv \
--input-driver GeoJSON \
--output-driver CSV \
--sql "SELECT name, ST_X(geometry) as lon, ST_Y(geometry) as lat
FROM cities"

Example: Filter by Complexity

geoetl-cli convert \
-i roads.geojson \
-o complex_roads.geojson \
--input-driver GeoJSON \
--output-driver GeoJSON \
--sql "SELECT * FROM roads
WHERE ST_NumPoints(geometry) > 100"

Complete Spatial SQL Reference

GeoETL v0.7.0 provides 36 spatial SQL functions:

CategoryFunctions
ConstructionST_Point, ST_MakePoint, ST_GeomFromText, ST_GeomFromWKB
MeasurementsST_Distance, ST_Area, ST_Length
PredicatesST_Intersects, ST_Contains, ST_Within, ST_Overlaps, ST_Touches, ST_Crosses, ST_Disjoint, ST_Equals, ST_Covers, ST_CoveredBy
GeneratorsST_Buffer, ST_Centroid, ST_Envelope, ST_ConvexHull, ST_Boundary, ST_PointOnSurface, ST_Simplify, ST_SimplifyPreserveTopology
Set OperationsST_Intersection, ST_Union, ST_Difference, ST_SymDifference
ValidatorsST_IsValid, ST_IsEmpty, ST_IsSimple, ST_IsClosed, ST_IsRing
AccessorsST_X, ST_Y, ST_NumPoints, ST_NumGeometries, ST_GeometryType, ST_Dimension