Opened 11 years ago
Closed 6 years ago
#4977 closed defect (fixed)
Negative pixel scale GeoTIFFs load geo info incorrectly
Reported by: | tclarke | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | GDAL_Raster | Version: | svn-trunk |
Severity: | normal | Keywords: | gtiff |
Cc: |
Description
See http://pastebin.com/jdmHDQTM for a example of the problem. GeoTIFFs with negative pix scale (south-up) do not load properly do to an ABS() in gdal/frmts/gtiff/geotiff.cpp
Attachments (1)
Change History (4)
comment:1 by , 11 years ago
Component: | default → GDAL_Raster |
---|---|
Keywords: | gtiff added |
comment:2 by , 9 years ago
I think this must be some corner case but I also think that the ticket is valid and amusing to study as well.
I started by creating created a south-up tiff+tfw combination. TFW was this:
1000.0000000000 0.0000000000 0.0000000000 1000.0000000000 50000.0000000000 100000.0000000000
Gdalinfo from this:
Corner Coordinates: Upper Left ( 49500.000, 99500.000) Lower Left ( 49500.000, 199500.000) Upper Right ( 149500.000, 99500.000) Lower Right ( 149500.000, 199500.000) Center ( 99500.000, 149500.000)
It appears that geotifcp (sic!) does not handle this situation:
geotifcp -e small.tfw small.tif small_geo.tif gdalinfo small_geo.tif Origin = (49500.000000000000000,100500.000000000000000) Pixel Size = (1000.000000000000000,-1000.000000000000000) Image Structure Metadata: INTERLEAVE=BAND Corner Coordinates: Upper Left ( 49500.000, 100500.000) Lower Left ( 49500.000, 500.000) Upper Right ( 149500.000, 100500.000) Lower Right ( 149500.000, 500.000) Center ( 99500.000, 50500.000)
I had to use listgeo + text editor + geotifcp for getting the desired geotiff tags into a new image file. Situation should be the same than with the south-up tiff+tfw
listgeo small2_geo.tif Geotiff_Information: Version: 1 Key_Revision: 1.0 Tagged_Information: ModelTiepointTag (2,3): 0.5 0.5 0 50000 100000 0 ModelPixelScaleTag (1,3): 1000 -1000 0 End_Of_Tags. Keyed_Information: End_Of_Keys. End_Of_Geotiff.
Gdalinfo shows extents as north-up with Y-pixel size as negative
gdalinfo small2_geo.tif Driver: GTiff/GeoTIFF Files: small2_geo.tif Size is 100, 100 Coordinate System is `' Origin = (49500.000000000000000,100500.000000000000000) Pixel Size = (1000.000000000000000,-1000.000000000000000) Image Structure Metadata: INTERLEAVE=BAND Corner Coordinates: Upper Left ( 49500.000, 100500.000) Lower Left ( 49500.000, 500.000) Upper Right ( 149500.000, 100500.000) Lower Right ( 149500.000, 500.000) Center ( 99500.000, 50500.000)
My conclusion is that TFW files are interpreted right but reversed Y-axis is not transferred into GeoTIFF by geotifcp not gdal_translate which I tried as well. And if GeoTIFF contains south-up pixel scale, GDAL does not honour it.
Question is that does this kind of south-up GeoTIFF files exist in real life, and how common are north-up GeoTIFFs which have a faulty, negative Y-pixel size. Correcting GDAL to honour the GeoTIFF specification would flip all images belonging to the latter group.
by , 9 years ago
Attachment: | test_tiffs.zip added |
---|
Plain tif+tfw (north-up and flipped) and GeoTIFF that should flip but doesn't
From the pastebin:
The problem appears to be this code in geotiff.cpp:
This ABS call was added in r395 without explanation but was presumably because some files were encountered with a negative pixelspace[1] when they didn't really mean that. On the other hand, the specification says this about ModelPixelScaleTag:
""" However, simple reversals of orientation between raster and model space (e.g. horizontal or vertical flips) may be indicated by reversal of sign in the corresponding component of the ModelPixelScaleTag. GeoTIFF compliant readers must honor this sign-reversal convention. """
This appears to make it clear we should not be disregarding the sign (in general).