ubarsc / rios

A raster processing layer on top of GDAL
https://www.rioshome.org
GNU General Public License v3.0
14 stars 8 forks source link

Disable SetLinearBinning() with HFA files, until its bugs are fixed #54

Closed neilflood closed 1 year ago

neilflood commented 1 year ago

There is a subtle bug in GDAL's HFA driver, which can cause HFA's binFunctionType field to have the wrong value after calculating statistics on the file, if the SetLinearBinning function is used when writing the histogram.

This bug only shows up when the file is then opened using ERDAS Imagine. GDAL pays no attention to this value, so all programs which read it using GDAL are unaffected.

The value of binFunctionType is wrong for files whose datatype is larger than 8-bit. When displaying the file using Imagine, it is unable to work out how to stretch the file, and it displays very badly. The raster data itself is not affected.

This pull request disables the use of SetLinearBinning for HFA files. It should remain in force until a fix for GDAL's HFA driver has been accepted and widely distributed.

There was a previous mechanism for disabling this in RIOS versions up until 1.4.10, but this was removed in 1.4.11 (Feb 2021). Any 16/32 bit HFA files written using versions 1.4.11 to 1.4.14 are thus suspect.

Ping @gillins.