ST_TransformPipeline — 返回一个新的几何图形,其坐标使用定义的坐标变换管道转换到不同的空间参考系统。
geometry ST_TransformPipeline(geometry g1, text pipeline, integer to_srid);
返回一个新的几何图形,其坐标使用定义的坐标变换管道转换到不同的空间参考系统。
变换管道使用以下任何一种字符串格式定义
urn:ogc:def:coordinateOperation:AUTHORITY::CODE。请注意,简单的 EPSG:CODE 字符串不能唯一标识坐标操作:同一个 EPSG 代码可以用于 CRS 定义。
PROJ 管道字符串的形式为:+proj=pipeline ...。不会应用自动轴归一化,如有必要,调用者需要添加额外的管道步骤,或删除 axisswap 步骤。
串联操作的形式为:urn:ogc:def:coordinateOperation,coordinateOperation:EPSG::3895,coordinateOperation:EPSG::1618。
可用性: 3.4.0
输入几何图形的 SRID 将被忽略,除非通过可选的 to_srid 参数提供值,否则输出几何图形的 SRID 将设置为零。当使用 `ST_TransformPipeline()` 时,管道将以正向方向执行。使用 ST_InverseTransformPipeline,管道将以反向方向执行。
使用管道的转换是 ST_Transform 的专门版本。在大多数情况下,`ST_Transform` 将选择正确的操作来在坐标系之间进行转换,并且应该优先使用。
使用 EPSG:16031 转换将 WGS 84 经纬度更改为 UTM 31N
-- Forward direction
SELECT ST_AsText(ST_TransformPipeline('SRID=4326;POINT(2 49)'::geometry,
'urn:ogc:def:coordinateOperation:EPSG::16031')) AS utm_geom;
utm_geom
--------------------------------------------
POINT(426857.9877165967 5427937.523342293)
(1 row)
-- Inverse direction
SELECT ST_AsText(ST_InverseTransformPipeline('POINT(426857.9877165967 5427937.523342293)'::geometry,
'urn:ogc:def:coordinateOperation:EPSG::16031')) AS wgs_geom;
wgs_geom
----------------------------
POINT(2 48.99999999999999)
(1 row)
GDA2020 示例。
-- using ST_Transform with automatic selection of a conversion pipeline.
SELECT ST_AsText(ST_Transform('SRID=4939;POINT(143.0 -37.0)'::geometry, 7844)) AS gda2020_auto;
gda2020_auto
-----------------------------------------------
POINT(143.00000635638918 -36.999986706128176)
(1 row)
-- using a defined conversion (EPSG:8447)
SELECT ST_AsText(ST_TransformPipeline('SRID=4939;POINT(143.0 -37.0)'::geometry,
'urn:ogc:def:coordinateOperation:EPSG::8447')) AS gda2020_code;
gda2020_code
----------------------------------------------
POINT(143.0000063280214 -36.999986718287545)
(1 row)
-- using a PROJ pipeline definition matching EPSG:8447, as returned from
-- 'projinfo -s EPSG:4939 -t EPSG:7844'.
-- NOTE: any 'axisswap' steps must be removed.
SELECT ST_AsText(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;
gda2020_pipeline
----------------------------------------------
POINT(143.0000063280214 -36.999986718287545)
(1 row)