Skip to main content

CRS Transformation

WherobotsDB provides coordinate reference system (CRS) transformation through the ST_Transform function. The transformation engine supports multiple CRS input formats and grid-based transformations for high-accuracy datum shifts.

Supported CRS Formats

WherobotsDB supports the following formats for specifying source and target coordinate reference systems.

Authority Code

The most common way to specify a CRS is using an authority code in the format AUTHORITY:CODE. WherobotsDB uses spatialreference.org as an open-source CRS database, which supports multiple authorities:
Output:
You can browse available CRS codes at spatialreference.org or EPSG.io.

WKT1 (OGC Well-Known Text)

WKT1 is the OGC Well-Known Text format for CRS definitions. It starts with PROJCS[...] for projected CRS or GEOGCS[...] for geographic CRS.

WKT2 (ISO 19162:2019)

WKT2 is the modern ISO 19162:2019 standard format. It starts with PROJCRS[...] for projected CRS or GEOGCRS[...] for geographic CRS.

PROJ String

PROJ strings provide a compact way to define CRS using projection parameters. They start with +proj=.

PROJJSON

PROJJSON is a JSON representation of CRS, useful when working with JSON-based workflows.

Grid File Support

Grid files enable high-accuracy datum transformations, such as NAD27 to NAD83 or OSGB36 to ETRS89. WherobotsDB supports loading grid files from multiple sources.

Grid File Sources

Grid files can be specified using the +nadgrids parameter in PROJ strings: WherobotsDB loads grids from local paths or full URLs. A bare filename such as +nadgrids=@us_noaa_conus.tif does not download a grid. Use its full PROJ CDN URL, or put a local grid at the same path on every executor. URL grids are downloaded once per executor JVM.

Optional vs Mandatory Grids

  • @ prefix (optional): If the grid cannot be loaded, the transformation continues without it and applies no datum shift.
  • No prefix (mandatory): The transformation fails if the grid cannot be loaded.

SQL Examples with Grid Files

Points that cannot be transformed

ST_Transform raises an error if a coordinate cannot be transformed, and the query fails. For example, Web Mercator (EPSG:3857) cannot represent latitudes 90 or -90. A point outside every loaded grid in a +nadgrids list also fails. Earlier releases returned NaN coordinates for these cases. Filter coordinates outside your target projection’s valid area before transforming them. Check grid coverage separately: making a grid optional allows a missing grid, but does not make a point outside a loaded grid valid. Some projections can return infinite or NaN coordinates without reporting an error. ST_Transform preserves those results, so a successful transformation does not guarantee finite coordinates.

Coordinate Order

WherobotsDB expects geometries to be in longitude/latitude (lon/lat) order. If your data is in lat/lon order, use ST_FlipCoordinates to swap the coordinates before transformation.
WherobotsDB automatically handles coordinate order in the CRS definition, ensuring the source and target CRS use lon/lat order internally.

Using Geometry SRID

If the geometry already has an SRID set, you can omit the source CRS parameter:

Function Signatures

For advanced use cases with an area of interest (experimental):

See Also