docs / geo
On this page
Geospatial
Coordinates are (longitude, latitude) on WGS84. This is not PostGIS.
Types and literals
WKT also coerces: POINT(lon lat), BOX(w s, e n), LINESTRING(...), POLYGON((...)).
CREATE SPATIAL INDEX requires a single POINT column (not UNIQUE). The optimizer uses a Morton geohash prefix for DWITHIN, DISTANCE(col, const) < r, WITHIN, and COVERS. The residual predicate is exact. EXPLAIN shows IndexScan … spatial.
Distances
DISTANCE is haversine meters. DISTANCE_SPHEROID is Vincenty on the WGS84 ellipsoid; near-antipodal pairs fall back to haversine.
DISTANCE, DWITHIN, INTERSECTS, and DISJOINT accept every pair of POINT, BOX, LINESTRING, and POLYGON. Also available: LON / LAT, COVERS, LINELENGTH, polygon AREA / PERIMETER, CENTROID, ENVELOPE, GEOMETRYTYPE, NPOINTS, NRINGS, and ST_* aliases. Polygon construction rejects self-intersections and invalid hole topology.
3D, geography-vs-geometry dual types, and spheroidal distance-to-polyline are not implemented. Engine note: `docs/geo.md`.