[gdal-dev] GDAL 3, PROJ 6.2 exportToProj4() drops Datum silently

Even Rouault even.rouault at spatialys.com
Tue Oct 29 07:59:22 PDT 2019


Roger,

> In looking at ways to adapt R packages rgdal and sf to current GDAL and
> PROJ, I have run into a problem. Many existing vector files (I have not
> yet looked at raster) include a datum declaration, which is still present
> internally in the OGRSpatialReference object, but is dropped in the output
> of exportToProj4().
> [...] 
> Using GetAttrValue("DATUM"), I can alert users who bother to see warnings
> that something has happened requiring their attention, but am I missing a
> CPL option or other remedy already in place?

No, you don't miss anything. PROJ 6 makes less efforts than previous verions 
to export a +datum= string. This is more or less intended so that people move 
away from PROJ strings to represent CRS because they suffer from a number of 
limitations (its hardcoded list of datums is very limited compared to what is 
available in EPSG, axis order issues, etc.). That particular use case could 
potentially be improved as +datum=OSGB36 is known of PROJ on the import side, 
but you'd get anyway into troubles with other datums.
If you use directly the WKT representation from this .prj file with PROJ 
functions that deal with coordinate transformations (or the 
OGRSpatialReference object with GDAL functions), things should work smoothly.

> Optional interpolation from GDALs gt_datum.csv or similar would perhaps
> help, inserting a +towgs84 tag, but I do not have a clear view how to make
> the migration process for users easier.

The towgs84 concept is also a fragile and a limited one. There might be 
several potential towgs84 transformations and this assumes you transforms 
from/to WGS84. That said the method OGRSpatialReference::importFromEPSG() will 
use internally proj_crs_create_bound_crs_to_WGS84() to try finding a TOWGS84 
transform. But this will only work if there's a single candidate. In case of 
multiple candidates, it will not select an artibtrary one like previous GDAL / 
PROJ versions did.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list