All Products
Search
Document Center

PolarDB:ST_Transform

Last Updated:Mar 28, 2026

Reprojects a trajectory's coordinate values from one spatial reference system to another. The input trajectory must have an SRID assigned; trajectories without an SRID cannot be transformed.

Syntax

trajectory ST_Transform(trajectory traj, int srid)

Parameters

ParameterDescription
trajThe trajectory to transform.
sridThe spatial reference identifier (SRID) of the target coordinate system.

Example

The following example transforms a trajectory from WGS 84 (SRID 4326) to the Beijing 1954 / 3-degree Gauss-Kruger CM 111E projection (SRID 2401). The SRID in the output changes from 4326 to 2401, and all coordinate values are reprojected accordingly.

-- Convert from WGS 84 (SRID 4326) to Beijing 1954 / 3-degree Gauss-Kruger CM 111E (SRID 2401)
SELECT ST_Transform(
  '{"trajectory":{"version":1,"type":"STPOINT","leafcount":4,"start_time":"2020-11-03 08:00:00","end_time":"2020-11-03 18:03:20","spatial":"SRID=4326;LINESTRING(114.49211 37.97999,114.49211 37.97521,114.49191 37.98021,124 37)","timeline":["2020-11-03 08:00:00","2020-11-03 08:01:40","2020-11-03 08:03:20","2020-11-03 18:03:20"]}}'::trajectory,
  2401
);

Output:

{"trajectory":{"version":1,"type":"STPOINT","leafcount":4,"start_time":"2020-11-03 08:00:00","end_time":"2020-11-03 18:03:20","spatial":"SRID=2401;LINESTRING(29019418.8397 5025539.47515,29019696.5878 5024992.53808,29019387.9428 5025555.44863,29954166.377 5430882.06455)","timeline":["2020-11-03 08:00:00","2020-11-03 08:01:40","2020-11-03 08:03:20","2020-11-03 18:03:20"]}}
(1 row)