Compares two spatial reference systems by parsing their semantics and returns true if they are equivalent.
Syntax
boolean ST_SrEqual(cstring sr1, cstring sr2, boolean strict default true);Parameters
| Parameter | Description |
|---|---|
| sr1 | The first spatial reference system. Must be an OGC WKT or PROJ.4 string. |
| sr2 | The second spatial reference system. Must be an OGC WKT or PROJ.4 string. |
| strict | Specifies whether to use strict comparison. When set to true, the function also compares the names of reference ellipsoids for georeferenced spatial reference systems. Default value: true. |
Description
ST_SrEqual parses the semantics of both spatial reference systems and compares their parameter information, including projection methods, reference ellipsoids, and the long and short axes of the reference ellipsoids. Returns t if the systems are equivalent, or f if they differ.
Examples
Compare two text-based spatial reference systems
The following example compares an OGC WKT string against a PROJ.4 string for the WGS 84 coordinate system.
select ST_srEqual('GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]', '+proj=longlat +datum=WGS84 +no_defs');Result:
st_srequal
------------
tLook up an SRID in the spatial_ref_sys table
The following example searches the spatial_ref_sys table for the spatial reference system identifier (SRID) that matches a PROJ.4 string.
select srid from spatial_ref_sys where st_srequal(srtext::cstring, '+proj=longlat +ellps=GRS80 +no_defs ') limit 1;Result:
srid
------
3824