PostGISSpatial Reference System

postgis_srs_codes

What is postgis_srs_codes?

postgis_srs_codes returns every SRS code defined by PROJ for a given authority (typically 'EPSG'). Useful for discovering which CRSs are usable on the current installation regardless of whether they appear in spatial_ref_sys. Available from PostGIS 3.4.

SQL
postgis_srs_codes(auth_name text) → SETOF text

The output is a set of authority-specific code strings — e.g. '4326', '3857', etc. for auth_name = 'EPSG'.

When would you use postgis_srs_codes?

Use postgis_srs_codes to build self-service CRS pickers in dashboards, check whether a required SRS is available in the deployed PROJ, or to audit discrepancies between PROJ's knowledge and the spatial_ref_sys table.

It is also a convenient input to postgis_srs to hydrate SRS metadata on demand without relying on the static spatial_ref_sys contents.

FAQs

Does it return codes not in spatial_ref_sys?

Yes. spatial_ref_sys ships with a snapshot; PROJ may know about additional codes not installed in the table. postgis_srs_codes reflects PROJ's live knowledge.

What authorities are supported?

Any authority PROJ supports — typically 'EPSG', 'ESRI', 'IAU_2015' (planetary), and 'OGC'. Pass the authority name as a string.

Is it slow?

It scans PROJ's database on each call. For repeated use in loops, cache the result in a temp table.

What version introduced it?

PostGIS 3.4.