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:
AuthorityDescriptionExample
EPSGEuropean Petroleum Survey GroupEPSG:4326, EPSG:3857
ESRIEsri coordinate systemsESRI:102008, ESRI:54012
IAUInternational Astronomical Union (planetary CRS)IAU:30100
SR-ORGUser-contributed definitionsSR-ORG:6864
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:
SourceFormatExample
Local fileAbsolute path+nadgrids=/path/to/grid.gsb
PROJ CDN@ prefix+nadgrids=@us_noaa_conus.tif
HTTPS URLFull URL+nadgrids=https://cdn.proj.org/us_noaa_conus.tif
When using the @ prefix, grid files are automatically fetched from PROJ CDN.

Optional vs Mandatory Grids

  • @ prefix (optional): The transformation continues without the grid if it’s unavailable. Use this when the grid improves accuracy but isn’t required.
  • No prefix (mandatory): An error is thrown if the grid file cannot be found.

SQL Examples with Grid Files

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