All Products
Search
Document Center

ApsaraDB RDS:ST_Transform

Last Updated:Sep 04, 2023

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.98158654713 111325.14286638486,111319.49079327357 111325.14286638486)
(1 row)