Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#7144 closed defect (fixed)

GDAL: GeoTIFF problem with custom ToWGS84

Reported by: dengo Owned by: warmerdam
Priority: normal Milestone: 2.2.3
Component: GDAL_Raster Version: 2.2.2
Severity: normal Keywords: GeoTIFF ToWGS84
Cc:

Description (last modified by dengo)

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).

Attachments (1)

GeoTIFF_ToWGS84_problem.zip (1.1 KB ) - added by dengo 6 years ago.

Download all attachments as: .zip

Change History (5)

by dengo, 6 years ago

Attachment: GeoTIFF_ToWGS84_problem.zip added

comment:1 by dengo, 6 years ago

Description: modified (diff)

comment:2 by Even Rouault, 6 years ago

Resolution: fixed
Status: newclosed

In 40683:

GTiff: on reading use GeogTOWGS84GeoKey to override the defaults TOWGS84 values coming from EPSG code (fixes #7144)

comment:3 by Even Rouault, 6 years ago

In 40684:

GTiff: on reading use GeogTOWGS84GeoKey to override the defaults TOWGS84 values coming from EPSG code (fixes #7144)

comment:4 by dengo, 6 years ago

Thanks for the fix, Even.

Note: See TracTickets for help on using tickets.