Skip to content

Instantly share code, notes, and snippets.

@ncclementi
Last active October 27, 2023 14:15
Show Gist options
  • Save ncclementi/fe53d75db2b9c049daefcbbbd5fe1ed4 to your computer and use it in GitHub Desktop.
Save ncclementi/fe53d75db2b9c049daefcbbbd5fe1ed4 to your computer and use it in GitHub Desktop.

Compatibility inventory of Postgress vs DuckDB geospatial fucntions

Here is a table of what we have in ibis/ibis/backends/base/sql/alchemy/registry.py compared against DuckDB spatial extension docs

ops postgress duckdb supported postgress docs
ops.GeoArea unary(sa.func.ST_Area) https://postgis.net/docs/ST_Area.html
ops.GeoAsBinary unary(sa.func.ST_AsBinary) https://postgis.net/docs/ST_AsBinary.html
ops.GeoAsEWKB unary(sa.func.ST_AsEWKB) https://postgis.net/docs/ST_AsEWKB.html
ops.GeoAsEWKT unary(sa.func.ST_AsEWKT) https://postgis.net/docs/ST_AsEWKT.html
ops.GeoAsText unary(sa.func.ST_AsText) https://postgis.net/docs/ST_AsText.html
ops.GeoAzimuth fixed_arity(sa.func.ST_Azimuth, 2) https://postgis.net/docs/ST_Azimuth.html
ops.GeoBuffer fixed_arity(sa.func.ST_Buffer, 2) https://postgis.net/docs/ST_Buffer.html
ops.GeoCentroid unary(sa.func.ST_Centroid) https://postgis.net/docs/ST_Centroid.html
ops.GeoContains fixed_arity(sa.func.ST_Contains, 2) https://postgis.net/docs/ST_Contains.html
ops.GeoContainsProperly fixed_arity(sa.func.ST_Contains, 2)
ops.GeoCovers fixed_arity(sa.func.ST_Covers, 2) https://postgis.net/docs/ST_Covers.html
ops.GeoCoveredBy fixed_arity(sa.func.ST_CoveredBy, 2) https://postgis.net/docs/ST_CoveredBy.html
ops.GeoCrosses fixed_arity(sa.func.ST_Crosses, 2) https://postgis.net/docs/ST_Crosses.html
ops.GeoDFullyWithin fixed_arity(sa.func.ST_DFullyWithin, 3) https://postgis.net/docs/ST_DFullyWithin.html
ops.GeoDifference fixed_arity(sa.func.ST_Difference, 2) https://postgis.net/docs/ST_Difference.html
ops.GeoDisjoint fixed_arity(sa.func.ST_Disjoint, 2) https://postgis.net/docs/ST_Disjoint.html
ops.GeoDistance fixed_arity(sa.func.ST_Distance, 2) https://postgis.net/docs/ST_Distance.html
ops.GeoDWithin fixed_arity(sa.func.ST_DWithin, 3) https://postgis.net/docs/ST_DWithin.html
ops.GeoEndPoint unary(sa.func.ST_EndPoint) https://postgis.net/docs/ST_EndPoint.html
ops.GeoEnvelope unary(sa.func.ST_Envelope) https://postgis.net/docs/ST_Envelope.html
ops.GeoEquals fixed_arity(sa.func.ST_Equals, 2) https://postgis.net/docs/ST_Equals.html
ops.GeoGeometryN fixed_arity(sa.func.ST_GeometryN, 2) ST_NGeometries is postgis ST_NumGeomtries Not imp https://postgis.net/docs/ST_GeometryN.html
ops.GeoGeometryType unary(sa.func.ST_GeometryType) https://postgis.net/docs/ST_GeometryType.html
ops.GeoIntersection fixed_arity(sa.func.ST_Intersection, 2) https://postgis.net/docs/ST_Intersection.html
ops.GeoIntersects fixed_arity(sa.func.ST_Intersects, 2) https://postgis.net/docs/ST_Intersects.html
ops.GeoIsValid unary(sa.func.ST_IsValid) https://postgis.net/docs/ST_IsValid.html
ops.GeoLineLocatePoint fixed_arity(sa.func.ST_LineLocatePoint, 2) https://postgis.net/docs/ST_LineLocatePoint.html
ops.GeoLineMerge unary(sa.func.ST_LineMerge) https://postgis.net/docs/ST_LineMerge.html
ops.GeoLineSubstring fixed_arity(sa.func.ST_LineSubstring, 3) https://postgis.net/docs/ST_LineSubstring.html
ops.GeoLength unary(sa.func.ST_Length) https://postgis.net/docs/ST_Length.html
ops.GeoNPoints unary(sa.func.ST_NPoints) https://postgis.net/docs/ST_NPoints.html
ops.GeoOrderingEquals fixed_arity(sa.func.ST_OrderingEquals, 2) https://postgis.net/docs/ST_OrderingEquals.html
ops.GeoOverlaps fixed_arity(sa.func.ST_Overlaps, 2) https://postgis.net/docs/ST_Overlaps.html
ops.GeoPerimeter unary(sa.func.ST_Perimeter) https://postgis.net/docs/ST_Perimeter.html
ops.GeoSimplify fixed_arity(sa.func.ST_Simplify, 3) ST_Simplify and ST_SimplifyPreserveTopology https://postgis.net/docs/ST_Simplify.html
ops.GeoSRID unary(sa.func.ST_SRID) https://postgis.net/docs/ST_SRID.html
ops.GeoSetSRID fixed_arity(sa.func.ST_SetSRID, 2) https://postgis.net/docs/ST_SetSRID.html
ops.GeoStartPoint unary(sa.func.ST_StartPoint) https://postgis.net/docs/ST_StartPoint.html
ops.GeoTouches fixed_arity(sa.func.ST_Touches, 2) https://postgis.net/docs/ST_Touches.html
ops.GeoTransform fixed_arity(sa.func.ST_Transform, 2) ST_Transform(GEOMETRY, VARCHAR, VARCHAR) https://postgis.net/docs/ST_Transform.html
ops.GeoUnaryUnion unary(sa.func.ST_Union) ST_Union_Agg https://postgis.net/docs/ST_Union.html
ops.GeoUnion fixed_arity(sa.func.ST_Union, 2) https://postgis.net/docs/ST_Union.html
ops.GeoWithin fixed_arity(sa.func.ST_Within, 2) https://postgis.net/docs/ST_Within.html
ops.GeoX unary(sa.func.ST_X) https://postgis.net/docs/ST_X.html
ops.GeoY unary(sa.func.ST_Y) https://postgis.net/docs/ST_Y.html

Missing Geospatial ops:

name on duckdb
ST_AsGML
ST_AsGeoJSON
ST_AsKML
ST_AsRaster
ST_AsSVG
ST_AsTWKB
ST_Distance_Sphere
ST_Dump
ST_DumpPoints
ST_GeogFromText
ST_GeomFromEWKB
ST_GeomFromEWKT
ST_GeomFromText

Note: There are multiple Spatial operations supported on DuckDB (check here) that are not part of the registry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment