Opened 9 years ago

Closed 8 months ago

#2440 closed defect (fixed)

ENVI dataset geotransform

Reported by: rsoconnor Owned by: warmerdam
Priority: normal Milestone:
Component: GDAL_Raster Version: unspecified
Severity: normal Keywords: ENVI
Cc: antonio

Description

There is a possible bug in file "envidataset.cpp" in line 567.

In the function WriteProjectionInfo?

    osLocation.Printf( "1, 1, %.15g, %.15g, %.15g, %.15g", 
                       adfGeoTransform[0], adfGeoTransform[3], 
                       adfGeoTransform[1], fabs(adfGeoTransform[5]) );

The last argument is hardcoded to be always positive. This will result in an incorrect transform if the true value is negative when the file is read back in.

I believe it should be:

    osLocation.Printf( "1, 1, %.15g, %.15g, %.15g, %.15g", 
                       adfGeoTransform[0], adfGeoTransform[3], 
                       adfGeoTransform[1], -adfGeoTransform[5] );

Attachments (2)

envi_geotransform_bug.py (745 bytes) - added by antonio 4 years ago.
Small test program to reproduce the issue
envi_geotransform_bug.patch (1.6 KB) - added by antonio 4 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 4 years ago by antonio

Cc: antonio added

Changed 4 years ago by antonio

Attachment: envi_geotransform_bug.py added

Small test program to reproduce the issue

Changed 4 years ago by antonio

Attachment: envi_geotransform_bug.patch added

comment:2 Changed 4 years ago by antonio

Please find attached a small test program to reproduce the issue and a patch implementing the solution suggested by rsoconnor (including a regression test).

Anyway I'm not sure that the proposed solution is OK since elements 6 and 7 of the "map info" parameter (see http://www.exelisvis.com/docs/ENVIRasterMetaData.html) should be x and y pixel sizes and I doubt they can have negative values.

The attached patch fixes the issue in GDAL but I don't know if it produces files that actually compatible with IDL/ENVI.

comment:3 Changed 3 years ago by Jukka Rahkonen

The fix feels safe from the GDAL point of view because in vast majority of cases the value of Y coordinate is decreasing from top to down and the result would be just the same. In optimal case we would have a real sample file created by ENVI and showing the Y value increasing from top to down. By reading the documentation about ENVI header file structure it is impossible to know how the "map info" field of such image would look like.

comment:4 Changed 2 years ago by Even Rouault

Priority: highnormal

All those tickets have more than one year and nobody has acted on it, so the priority is not so high

comment:5 Changed 8 months ago by Even Rouault

Resolution: fixed
Status: newclosed

Probably obsoleted by the fix done in #1778

Note: See TracTickets for help on using tickets.