ST_TransformPipeline
Name
ST_TransformPipeline — Return a new geometry with coordinates transformed to a different spatial reference system using a defined coordinate transformation pipeline.
Synopsis
geometry
ST_TransformPipeline
(
geometry
g1
, text
pipeline
, integer
to_srid
)
;
Description
Return a new geometry with coordinates transformed to a different spatial reference system using a defined coordinate transformation pipeline.
Transformation pipelines are defined using any of the following string formats:
-
urn:ogc:def:coordinateOperation:AUTHORITY::CODE. Note that a simpleEPSG:CODEstring does not uniquely identify a coordinate operation: the same EPSG code can be used for a CRS definition. -
A PROJ pipeline string of the form:
+proj=pipeline .... Automatic axis normalisation will not be applied, and if necessary the caller will need to add an additional pipeline step, or removeaxisswapsteps. -
Concatenated operations of the form:
urn:ogc:def:coordinateOperation,coordinateOperation:EPSG::3895,coordinateOperation:EPSG::1618.
Availability: 3.4.0
The SRID of the input geometry is ignored, and the SRID of the output geometry will be set to
zero unless a value is provided via the optional
to_srid
parameter. When
using `ST_TransformPipeline()` the pipeline is executed in a forward direction. Using
ST_InverseTransformPipeline
the pipeline is executed in the inverse direction.
Transforms using pipelines are a specialised version of ST_Transform . In most cases `ST_Transform` will choose the correct operations to convert between coordinate systems, and should be preferred.
Examples
Change WGS 84 long lat to UTM 31N using the EPSG:16031 conversion
This example transforms in the forward direction.
SELECT
ST_SetSRID(ST_TransformPipeline(
'SRID=4326;POINT(2 49)'::geometry,
'urn:ogc:def:coordinateOperation:EPSG::16031'
), 32631) AS utm_geom;
SRID=32631;POINT(426857.9877165967 5427937.523342293)
This example transforms in the inverse direction.
SELECT
ST_SetSRID(ST_InverseTransformPipeline(
'SRID=32631;POINT(426857.9877165967 5427937.523342293)'::geometry,
'urn:ogc:def:coordinateOperation:EPSG::16031'
), 4326) AS wgs_geom;
SRID=4326;POINT(2 48.99999999999999)
GDA2020 example.
This example uses ST_Transform with automatic selection of a conversion pipeline.
SELECT ST_Transform('SRID=4939;POINT(143.0 -37.0)'::geometry, 7844) AS gda2020_auto;
POINT(143.00000635638918 -36.999986706128176)
Using a defined conversion (EPSG:8447)
SELECT
ST_TransformPipeline(
'SRID=4939;POINT(143.0 -37.0)'::geometry,
'urn:ogc:def:coordinateOperation:EPSG::8447'
) AS gda2020_code;
POINT(143.0000063280214 -36.999986718287545)
This example uses a PROJ pipeline definition matching EPSG:8447, as returned from projinfo. Any axisswap steps must be removed.
SELECT
ST_TransformPipeline(
'SRID=4939;POINT(143.0 -37.0)'::geometry,
'+proj=pipeline
+step +proj=unitconvert +xy_in=deg +xy_out=rad
+step +proj=hgridshift +grids=au_icsm_GDA94_GDA2020_conformal_and_distortion.tif
+step +proj=unitconvert +xy_in=rad +xy_out=deg'
) AS gda2020_pipeline;
POINT(143.0000063280214 -36.999986718287545)