GDALMetadata

gdalsrsinfo

What is gdalsrsinfo?

gdalsrsinfo reports the coordinate reference system of a dataset — or of a bare CRS definition — in multiple formats: WKT1, WKT2, PROJ string, EPSG code, ESRI WKT, XML, and more. It is the right tool for decoding what CRS a file actually has, for converting between CRS notations, and for validating that a CRS definition is well-formed.

Shell
gdalsrsinfo [options] <srs_def>

Commonly used options:

  • -o <format> — output format: default, all, wkt_all, wkt1, wkt2, wkt2_2015, wkt2_2019, wkt_simple, wkt_noct, wkt_esri, proj4, epsg, xml, mapinfo, usgs
  • -p — pretty-print WKT
  • -V — validate the CRS string

<srs_def> may be a filename (raster or vector), an EPSG code (EPSG:4326), a WKT string, a PROJ string, or a path to a .prj file.

When would you use gdalsrsinfo?

Use gdalsrsinfo whenever you need to know, verify, or translate a CRS. Typical jobs: confirming a GeoTIFF's CRS matches what a client promised (gdalsrsinfo scene.tif), extracting a clean PROJ string for use in another tool (gdalsrsinfo -o proj4 EPSG:25832), translating an ESRI WKT from a delivered .prj into a modern WKT2 (gdalsrsinfo -o wkt2_2019 delivered.prj), or validating that a hand-written WKT actually parses (gdalsrsinfo -V "PROJCS[...]").

For scripting, -o epsg tries to discover the EPSG code for the input CRS — useful when a file carries a full WKT but you want a compact code. -o all is the go-to "show me everything" mode when debugging a stubborn CRS mismatch. Paired with gdalinfo -json | jq .coordinateSystem.wkt, it makes CRS auditing across a dataset catalogue a one-liner.

FAQs

How do I find the EPSG code of a file's CRS?

gdalsrsinfo -o epsg file.tif. The command attempts to match the CRS against the EPSG database and emit the matching code if one exists. Note that custom or slightly-modified CRSes may not match any EPSG code exactly, in which case the output is blank and you should inspect the WKT.

WKT1 vs WKT2 — which should I use?

WKT2 (specifically wkt2_2019) is the modern standard and expresses datum and CRS hierarchy more precisely. Older tools (pre-GDAL 3, pre-PROJ 6, ArcGIS pre-10.8) want WKT1. For interop with modern tools, default to WKT2; for sharing with legacy systems, wkt1 or wkt_esri is safer.

Can gdalsrsinfo read a .prj sidecar?

Yes — pass the .prj path directly. This is handy for Shapefile deliveries where the CRS lives in a sidecar, and for comparing .prj contents across files without opening them in a GIS.

What does -V actually validate?

-V runs the CRS through GDAL/PROJ's parser and structural validation, reporting whether the definition is syntactically valid and internally consistent. It does not check semantic correctness against reality — a well-formed WKT that names the wrong datum will validate cleanly.