ST_SetSRID

更新时间:
复制 MD 格式

Sets a spatial reference identifier (SRID) on a geometry object without transforming its coordinates.

Syntax

geometry ST_SetSRID(geometry geom, integer srid);

Parameters

ParameterDescription
geomThe geometry object.
sridThe SRID to assign to the geometry object.

Usage notes

ST_SetSRID only sets the metadata that defines the spatial reference system in which the geometry object resides. It does not reproject or transform the coordinates.

To transform a geometry object into a different projection, use ST_Transform instead.

ST_SetSRID supports circular strings and curves.

Examples

Assign SRID 4326 (WGS 84) to a line string and return the result in EWKT format:

SELECT ST_AsEWKT(ST_SetSRID(ST_GeomFromText('LINESTRING(2 1,1 1)'), 4326));

Output:

           st_asewkt
-------------------------------
 SRID=4326;LINESTRING(2 1,1 1)
(1 row)