Opened 11 years ago

Closed 11 years ago

#5069 closed defect (fixed)

gdalwarp fails warping tiffs with different resolution units

Reported by: cdestigter Owned by: Robert Coup
Priority: normal Milestone:
Component: GDAL_Raster Version: 1.10.0
Severity: normal Keywords:
Cc:

Description (last modified by cdestigter)

We've got two tiffs here, one with pixels/inch and the other with pixels/cm resolution units. Goodness knows why, but I'd assume gdal could multiply out the resolutions properly when merging them.

rm -f out.tif ; gdalwarp -of GTiff -co TILED=YES -co COMPRESS=DEFLATE -te 19296899.6093 -4620876.43484 19453442.6432 -4464333.40091 -ts 500 500 inch.tif cm.tif out.tif
Creating output file that is 500P x 500L.
Processing input file inch.tif.
0...10...20...30...40...50...60...70...80...90...100 - done.
Processing input file cm.tif.
0...10...20...30...40...50...60...70...80...90...100 - done.
ERROR 1: _TIFFVSetField:out.tif: Bad value 0 for "ResolutionUnit" tag

Our gdal was built from our github fork, ie https://github.com/koordinates/gdal/tree/252ed79 which is basically 1.10 branch from about 10 days ago.

Attachments (2)

cm.tif (31.5 KB ) - added by cdestigter 11 years ago.
inch.tif (31.5 KB ) - added by cdestigter 11 years ago.

Download all attachments as: .zip

Change History (8)

by cdestigter, 11 years ago

Attachment: cm.tif added

by cdestigter, 11 years ago

Attachment: inch.tif added

comment:1 by cdestigter, 11 years ago

Description: modified (diff)

comment:2 by Robert Coup, 11 years ago

I think https://github.com/OSGeo/gdal/blob/trunk/gdal/frmts/gtiff/geotiff.cpp#L5047 is the culprit:

else if( EQUAL(pszItemName,"TIFFTAG_RESOLUTIONUNIT") )
   TIFFSetField( hTIFF, TIFFTAG_RESOLUTIONUNIT, atoi(pszItemValue) );

atoi('*') will return 0, but it looks like TIFFTAG_RESOLUTIONUNIT=1 is 'unknown', 0 isn't a valid value.

comment:3 by cdestigter, 11 years ago

ah, FYI those two tiffs are licensed CC-BY, from LINZ. They're two tiles from http://data-test.linz.govt.nz/#/layer/169-nz-mainland-terrain-relief-topo-50/

(super downscaled, obviously)

comment:4 by cdestigter, 11 years ago

ah, FYI those two tiffs are licensed CC-BY, from LINZ. They're two tiles from http://data.linz.govt.nz/#/layer/765-nz-terrain-relief-topo50/

(super downscaled, obviously)

If an admin could delete my last comment I'd appreciate it, posted internal link by accident.

comment:5 by Robert Coup, 11 years ago

Owner: changed from warmerdam to Robert Coup
Status: newassigned

comment:6 by Robert Coup, 11 years ago

Resolution: fixed
Status: assignedclosed

Fixed in [25973] (trunk) and [25974] (1.10). When a non-integer value (eg. "*" or "") is presented for TIFFTAG_RESOLUTIONUNIT, we set it to 1 (unknown)

Note: See TracTickets for help on using tickets.