Skip to content

Spatial Reference System Functions

Idan Sheinberg edited this page Jul 1, 2022 · 9 revisions

ST_Transform

To SRID variant

Description: Returns a new geometry with its coordinates transformed to a different spatial reference system
Input Argument #1: Geometry (WKB)
Input Argument #2: Target CRS SRID (Integer) Output: Geomery (WKB)

SELECT ST_AsText(
  ST_Transform(
    ST_GeomFromText(
      'POLYGON((743238 2967416,743238 2967450,743265 2967450,743265.625 2967416,743238 2967416))',
      2249
    ),
    4326
  )
) AS wgs84_geom;

Result

POLYGON ((-71.1776848522251 42.39028965129019, -71.17768437663263 42.390382947800894, -71.17758443054647 42.39038266779173, -71.17758259272306 42.39028936479872, -71.1776848522251 42.39028965129019))

Note #1
PostGIS overloaded variants supporting direct PROJ 4 string injection are not (yet) implemented

Note #2
Supported SRIDs are defined in LocationTech's PROJ4 binding

Note #3
Be sure input geometries, whether serialized from text WKT or WKB, are loaded with the proper SRID definition.
That is a prerequisite in order for this function to operate properly, as the source SRID is used to compute the proper transformation

To PROJ4 string variant

From PROJ4 string to SRID variant

Clone this wiki locally