ST_SetSRID

更新时间:
复制 MD 格式

Sets the spatial reference identifier (SRID) on a geometry object. Useful for marking a geometry with the coordinate system it uses before querying or transforming it.

Syntax

geometry ST_SetSRID(geometry geom, integer srid);

Parameters

ParameterDescription
geomThe geometry object.
sridThe SRID of the geometry object.

Usage notes

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

    Note

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

  • ST_SetSRID supports circular strings and curves.

Examples

Example 1: Mark a line as WGS 84 (SRID 4326)

-- Mark a LINESTRING as WGS 84 (long/lat)
SELECT ST_AsEWKT(ST_SetSRID(ST_GeomFromText('LINESTRING(2 1,1 1)'), 4326));

Result:

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

See also

  • ST_SRID — Get the SRID of a geometry object

  • ST_Transform — Transform a geometry object into a different spatial reference system

  • UpdateGeometrySRID — Update the SRID of all geometry objects in a table column