Skip to content

ST_Transform

Transforms a geometry from one coordinate reference system to another.

Usage

geometry ST_Transform(geom: geometry, target_crs: string)
geometry ST_Transform(geom: geometry, source_crs: string, target_crs: string)

Arguments

  • geom (geometry): Input geometry
  • source_crs (string)
  • target_crs (string)

Description

Transforms the coordinate reference system of a geometry between EPSG reference systems. If provided with 2 arguments, target_crs can be specified as an EPSG code (e.g., ‘EPSG:4326’) or as a PROJ string.

When 3 arguments are provided, a source_crs can be used to specify the source CRS in case the input geometry doesn’t have an SRID defined. The source_crs takes precedence over the geometry’s SRID.

Examples

SELECT ST_Transform(ST_SetCRS(ST_Point(-122.35, 47.65), 'EPSG:4326'), 'EPSG:26910');
┌──────────────────────────────────────────────────────────────────────────────┐
│ st_transform(st_setcrs(st_point(Float64(-122.35),Float64(47.65)),Utf8("EPSG: │
│                         4326")),Utf8("EPSG:26910"))…                         │
╞══════════════════════════════════════════════════════════════════════════════╡
│ POINT(548814.0314153476 5277605.006574745)                                   │
└──────────────────────────────────────────────────────────────────────────────┘