名稱

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)