This topic describes the ST_Transform function. This function transforms the original spatial reference system in which a geometry object resides into a new spatial reference system.

Syntax

geometry  ST_Transform(geometry  g1 , integer  srid);
geometry  ST_Transform(geometry  geom , text  toProj);
geometry  ST_Transform(geometry  geom , text  fromProj , text  toProj);
geometry  ST_Transform(geometry  geom , text  fromProj , integer  toSrid);

Parameters

Parameter Description
g1/geom The geometry object that you want to specify.
srid/toSrid The SRID of the new spatial reference system. The SRID that you specify must be stored in the space_ref_sys table.
toProj The PROJ string that defines the new spatial reference system.
fromProj The PROJ string that defines the original spatial reference system.

Description

The ST_Transform function supports circular strings, curves, and polyhedral surfaces.

Examples

SELECT ST_AsEWKT(ST_Transform(ST_GeomFromText('LINESTRING(2 1,1 1)',4326),3857));
                           st_asewkt
---------------------------------------------------------------
 SRID=3857;LINESTRING(222638.981586547 111325.142866385,111319.
..490793274 111325.142866385)
(1 row)