[gdal-dev] epsg_tr.py in reverse?

Frank Warmerdam warmerdam at pobox.com
Fri Feb 29 23:11:27 EST 2008


Moskovitz, Bob wrote:
> Hello All,
> 
> I would like to find a utility that would allow you to find the EPSG code
> given a proj4 string.  Sort of a epsg_tr.py in reverse.  Can a utility be
> written with the gdal api to do that?

Bob,

You could walk the whole list of EPSG coordinate systems, import each
to an OGRSpatialReference object, and then use the OGRSpatialReference
IsSame() method to compare it to an OGRSpatialReference imported from
a PROJ.4 definition.  This would, in theory, let you find a match.  But
in practice this is computationally expensive and the IsSame() method is
flakey in a number of regards (too sensitive to some differences such as
order, and not aware of other differences like prime meridian).

Another approach would be to convert them all to PROJ.4 format and do exact
string comparisons.  You would need to convert the original (target) PROJ.4
definition to WKT and convert it back to PROJ.4 too, so it would be
"normalized" to the style of PROJ.4 produced by OGR.

This would likely work fairly well, but would still be sensitive to
different numeric precision for parameters.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGeo, http://osgeo.org



More information about the gdal-dev mailing list