All Products
Search
Document Center

PolarDB:ST_Transform

Last Updated:Mar 28, 2026

ST_Transform converts a geometry object from one spatial reference system to another, updating both the coordinates and the spatial reference system identifier (SRID).

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

ParameterDescription
g1/geomThe geometry object to transform.
srid/toSridThe SRID of the target spatial reference system. The SRID must exist in the space_ref_sys table.
toProjThe PROJ string that defines the target spatial reference system.
fromProjThe PROJ string that defines the source spatial reference system. Use this parameter when the input geometry has no SRID set.

Usage notes

  • ST_Transform supports circular strings, curves, and polyhedral surfaces.

  • If the input geometry has no SRID, specify fromProj to define the source spatial reference system.

  • The SRID passed to srid or toSrid must exist in the space_ref_sys table.

Examples

Transform using a target SRID

Convert a LINESTRING from WGS 84 geographic coordinates (EPSG:4326) to Web Mercator (EPSG:3857):

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)