[gdal-dev] How get EPSG code from an OGRSpatialReferenceH?

Nik Sands nixanz at nixanz.com
Thu Aug 28 19:42:35 PDT 2014


Hi devs,

What is the correct way to extract the EPSG code from an OGRSpatialReferenceH ?

Currently I'm finding that the following works only for SRS of some images and not others:

	const char *charAuthType = OSRGetAttrValue(gdal.srcSRS, "AUTHORITY", 0);
	const char *charSrsCode = OSRGetAttrValue(gdal.srcSRS, "AUTHORITY", 1);

However, there is no "AUTHORITY" node in some SRSs so it doesn't work for those images.  To cater for this, I'm trying to explicitly set the authority node using:

	OSRAutoIdentifyEPSG(gdal.srcSRS);

But this fails with OGRERR_UNSUPPORTED_SRS (even when it is an SRS that GDAL recognises and uses well).

So I'm stumped... how do I reliably determine the EPSG for an OGRSpatialReferenceH?

Cheers,
Nik.



More information about the gdal-dev mailing list