[gdal-dev] Unable to create OGRSpatialReference

Even Rouault even.rouault at mines-paris.org
Fri Oct 19 11:35:08 PDT 2012


Le vendredi 19 octobre 2012 16:41:14, jcurru a écrit :
> Hello!
> 
> I have an old problem with TOWGS84 and OGRSpatialReference. Most likely
> it's because I'm no expert in GDAL. It is important for my project, and
> limits many of its capabilities. The fact is that, for unknown reasons (to
> me), proj4 does not do well conversions between coordinate system if there
> are not a TOWGS84 nodes inside the OGRSpatialReference(s).
> 
> First of all: is this so? Do I really need that node? If not properly
> added, clearly some conversions fail.

The best is to point you to some reference documentation :

http://trac.osgeo.org/proj/wiki/GenParms#towgs84-DatumtransformationtoWGS84
http://docs.geotools.org/stable/javadocs/org/opengis/referencing/doc-
files/WKT.html#TOWGS84

> 
> I continue: Imagine getting an OGRSpatialReference a shapefile or a TIF. To
> assign the node TOWGS84, what I do is look into the file "EPSG", found in
> many sites related to GDAL, that contains a list of EPSGs with
> corresponding parameters. Knowing the EPSG, I can generate the TOWGS84
> node smoothly.
> 
> The problem comes when I do not know the OGRSpatialReference’s EPSG,
> something very common: AutoIdentifyEPSG () gets nothing most of the time,
> at least with the systems in which I work.
> 
> So what to do then? I need the TOWGS84 node but, with my knowledge, I can
> only get it from the EPSG.

This is indeed a difficulty that is not easily solved. The WKT in .prj that come 
alongside with shapefiles is in ESRI WKT that stripps TOWGS84 information. And 
most geotiff don't include TOWGS84 : the GeoTIFF format has only been extended 
very recently to convey TOWGS84 : 
http://trac.osgeo.org/geotiff/wiki/TOWGS84GeoKey

And indeed AutoIdentifyEPSG() only works a few common cases, mainly EPSG:4326, 
EPSG:326XX & EPSG:327XX (WGS84 UTM projections), EPSG:267XX (NAD27 UTM 
projections) and EPSG:269XX (NAD83 UTM projections).


More information about the gdal-dev mailing list