[Gdal-dev] Datum shifting
hgrabows at stk.com
Wed Dec 10 13:00:14 EST 2003
I read through the archive and it appears that datum shifting should be
available in the OGR libraries, but I'm having issues with this. I got
the binary form of PROJ.4 from the website, as well as downloaded the
data files for the shifts. My application sets the environment variable
leading to those data files, per the suggestion of the PROJ.4 site.
It's just not happening. My situation is that I'm trying to
automatically reproject ESRI shapefiles into WGS84 for my application.
As long as the projection uses a WGS84 datum, everyone is happy. If it
doesn't use this datum then the data generated comes out in a
nonsensical fashion. I've tried doing it from the command line ogr2ogr
that I built with the standard GDAL build scripts with a similar issue,
but in the form of an error. In both cases I have an environment
variable PROJ_LIB set to the directory where the data files like
"nad27","nad83", and "alaska.lla" are stored.
In the command line case, I can correctly reproject a shape file with
data in an Albers projection using the following command:
ogr2ogr -t_srs WGS84 out.shp cities_alb.shp
However if I do the same thing with a shape file with its geometry in a
NAD 1927 UTM Zone 16N projection I get the following result:
This command: ogr2ogr -t_srs WGS84 out.shp roads.shp
produces this error message:
ERROR 1: failed to load NAD27-83 correction file
Failed to transform feature 0.
ERROR 1: Terminating translation prematurely after failed
translation of layer roads
I assume the two are related. In code, I'm doing a very similar thing.
I create a new shape file data source and get the shapefile as a layer.
I pull the spatial reference for that layer and create a default WGS84
spatial reference. I then create a new coordinate transformation object
and use that to transform a Geometry collection. The relevent code
snippet looks like this:
pLayer = pDS->GetLayerByName(featureName);
pOrig = pLayer->GetSpatialRef();
err = srWGS84.SetWellKnownGeogCS("WGS84");
pCoordTrans = OGRCreateCoordinateTransformation(pOrig,&srWGS84);
Again, this works for Albers projections, but not the NAD based
projection that I tried above. It doesn't throw an error, but it also
doesn't. If I manually transform the data in ArcGIS I get a valid
transformation, so I know an accurate conversion is possible.
Hopefully this provides enough information to provide some assistance.
You guys have done a good job with this library, and I'd like to express
my appreciation for the time you have put into developing and
hgrabowski at stk.com
Experience the analysis and visualization power of STK 5.0 by upgrading
today! Order your free copy at http://www.stk.com to get started!
More information about the Gdal-dev