[gdal-dev] [Projections] EPSG, proj.4, .prj files

Even Rouault even.rouault at mines-paris.org
Wed May 11 14:35:57 EDT 2011


Le mercredi 11 mai 2011 20:20:51, Paul Meems a écrit :
> Hi List,
> 
> We use GDAL with Proj.4 in MapWindow GIS.
> We're currently in the process of upgrading to GDAL v1.8
> 
> We have some issues with projections in MapWindow.
> We partially us GDAL methods and partially our custom ones.
> We also are more and more working with EPSG codes with WMS and WFS. So we
> need to handle them as well.
> 
> I've seen a discussion about this 2 or 3 weeks ago and my question
> partially overlaps.
> As I understand it, it is not possible do use GDAL/Proj.4 to input a EPSG
> code and get the prj-file or projection string back, right?

If I were you, I would look at the importFromEPSG() and exportToProj4() / 
exportToWkt() methods of OGRSpatialReference ....

> And the same is for the other way round: get the EPSG code when the input
> is a projection string.

Generally not, unless there's a AUTHORITY node in the WKT. There's also a 
OGRSpatialReference::AutoIdentifyEPSG() method, but it will work only in a few 
cases. Have a look at its implementation to know which ones.

One possibility to identify the EPSG code is to iterate over all the EPSG code 
and get their proj4 representation, and compare that to the proj4 
representation of your projection string. But that's not a perfect solution 
and I'm not sure there's a perfect solution. The proj4 representation isn't a 
bijection of the WKT representation.

> 
> But we do want this. Is some sort of offline database or XML file available
> that will show the EPSG codes with the accompanying prj-file text and
> projection string?

Are you looking for the "epsg" file from the proj.4 distribution... ? 
http://trac.osgeo.org/proj/browser/trunk/proj/nad/epsg

Illustrating my point in previous paragraph :

# CHTRF95
<4151> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>
# NAD83(HARN)
<4152> +proj=longlat +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +no_defs  <>

2 EPSG codes, same PROJ.4 representation

> 
> Or am I thinking in the wrong direction?
> 
> Thanks,
> 
> Paul
> 
> 
> *Paul Meems *
> Release manager, configuration manager
> and forum moderator of MapWindow GIS.
> www.mapwindow.org
> 
> Owner of MapWindow.nl - Support for
> Dutch speaking users.
> www.mapwindow.nl
> 
> *
> *


More information about the gdal-dev mailing list