Skip to content
Prev 16574 / 29559 Next

readGDAL loses datum

On Fri, 2 Nov 2012, Roger Bivand wrote:

            
I've committed to the rgdal R-Forge project a user argument to relevant 
functions in rgdal for setting the behaviour to datum-preserving, either 
on a case-by-case or global level. If the environment variable is present, 
it will have precedence and will not be overwritten. I'd welcome reports 
from those who can try out the source checked out from R-forge.

In your case, I now see:
img1.tif has GDAL driver GTiff
and has 1 rows and 1 columns
[1] " +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 
+ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
OVERRIDE_PROJ_DATUM_WITH_TOWGS84=FALSE))
img1.tif has GDAL driver GTiff
and has 1 rows and 1 columns
[1] " +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 
+datum=NAD83 +units=m +no_defs +ellps=GRS80 +towgs84=0,0,0"

However, there does not seem to be a clear way to auto-detect and set the 
switch. The package also has a cached variable, so setting:

set_OVERRIDE_PROJ_DATUM_WITH_TOWGS84(FALSE)

in an R session will use that value when raster projections are read until 
the setting is changed. The argument will not be used for GDAL < 1.8.0, 
because its use first appeared there. It will also not be used if an 
environment variable "OVERRIDE_PROJ_DATUM_WITH_TOWGS84" is found, to avoid 
overwriting its value.

This is the result of discussions on the gdal-dev list, thread starting 
at:

http://lists.osgeo.org/pipermail/gdal-dev/2012-November/034550.html

and details in:

http://trac.osgeo.org/gdal/ticket/4880

Roger