postgis_srs_search
Prev  7.7. Spatial Reference System Functions  Next

Name

postgis_srs_search — Return metadata records for projected coordinate systems that have areas of usage that fully contain the bounds parameter.

Synopsis

setof record postgis_srs_search(geometry bounds, text auth_name=EPSG);

Description

Return a set of metadata records for projected coordinate systems that have areas of usage that fully contain the bounds parameter. Each record will have the auth_name, auth_srid, srname, srtext, proj4text, and the corners of the area of usage, point_sw and point_ne.

The search only looks for projected coordinate systems, and is intended for users to explore the possible systems that work for the extent of their data.

Availability: 3.4.0

Proj version 6+

Examples

Search for projected coordinate systems in Louisiana.

Code
SELECT auth_name, auth_srid, srname,point_sw AS point_sw,point_ne AS point_ne
FROM postgis_srs_search('SRID=4326;LINESTRING(-90 30,-91 31)')
WHERE auth_srid IN ('2801', '3452', '3457')
ORDER BY auth_name, auth_srid::integer
Output
-[ RECORD 1 ]----------
auth_name | EPSG
auth_srid | 2801
srname    | NAD83(HARN) / Louisiana South
point_sw  | POINT(-93.94 28.85)
point_ne  | POINT(-88.75 31.07)
-[ RECORD 2 ]----------
auth_name | EPSG
auth_srid | 3452
srname    | NAD83 / Louisiana South (ftUS)
point_sw  | POINT(-93.94 28.85)
point_ne  | POINT(-88.75 31.07)
-[ RECORD 3 ]----------
auth_name | EPSG
auth_srid | 3457
srname    | NAD83(HARN) / Louisiana South (ftUS)
point_sw  | POINT(-93.94 28.85)
point_ne  | POINT(-88.75 31.07)
EPSG | 2801 | NAD83(HARN) / Louisiana South | 0101000020E61000005C8FC2F5287C57C09A99999999D93C40 | 0101000020E610000000000000003056C052B81E85EB113F40
EPSG | 3452 | NAD83 / Louisiana South (ftUS) | 0101000020E61000005C8FC2F5287C57C09A99999999D93C40 | 0101000020E610000000000000003056C052B81E85EB113F40
EPSG | 3457 | NAD83(HARN) / Louisiana South (ftUS) | 0101000020E61000005C8FC2F5287C57C09A99999999D93C40 | 0101000020E610000000000000003056C052B81E85EB113F40
Figure
Geometry figure for visual-postgis-srs-search-01

Scan a table for max extent and find projected coordinate systems that might suit.

Code
WITH ext AS (
  SELECT ST_Extent(geom) AS geom, Max(ST_SRID(geom)) AS srid
  FROM foo
)
SELECT auth_name, auth_srid, srname,
  point_sw AS point_sw,
  point_ne AS point_ne
FROM ext
CROSS JOIN postgis_srs_search(ST_SetSRID(ext.geom, ext.srid))
LIMIT 3;

See Also

postgis_srs_codes, postgis_srs_all, postgis_srs

Prev  Up  Next
postgis_srs_all  Home  ST_BdPolyFromText