GDAL: GeoTIFF problem with custom ToWGS84
|Reported by:||dengo||Owned by:||warmerdam|
Description (last modified by )
We've noticed an issue when creating a GeoTIFF with custom ToWGS84 values. When reopening the raster the custom ToWGS84 values are lost.
Looking into the GDAL Code I've found that the correct values are read and set to oSRS (gt_wkt_srs.cpp Line 768), but a few lines below the oSRS is replaced with oSRSTmp that is imported from the EPSG code only. When the config option GTIFF_IMPORT_FROM_EPSG is set to NO, the ToWGS84 values are correctly preserved, but there will probably be problems with other rasters, so it's probably not a good idea to disable this config option in general.
I've attached a GeoTiff file where this problem can be observed.
It seems a similar problem was reported before regarding the linear units being lost and a workaround has been added(https://trac.osgeo.org/gdal/ticket/6210).
Perhaps a similar workaround needs to be added for the ToWGS84 values or the GTIFF_IMPORT_FROM_EPSG part should be moved above the part where the ToWGS84 values are set. In general the GTIFF_IMPORT_FROM_EPSG part seems a bit out of place, because there are multiple instructions above that might adjust oSRS.
Another small issue i've noticed is, that the original Projection Name is lost regardless of the GTIFF_IMPORT_FROM_EPSG config option, but this might be the desired outcome. The name from the Tiff header is only used when GTIFGetPCSInfo(psDefn->PCS,..) did not return a name (the corresponding code can be found in gt_citation.cpp Line 515).