Bug report #4388
Bug report #8417: incorrect value loaded from netcdf file with scale factor
gdal raster provider does not use Offset and Scale raster properties
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||14320|
When QGis opens a GDAL raster with Offset and Scale properties, it does not recognize these values and the displayed values are not correct.
Attaching an example dataset (in gtiff and netcdf format) which has Offset and Scale.
A simple fix would be to compute the values with the following display (when Offset and Scale are present):
new_value = (raw_value * scale) + offset
I can try to write a fix, however I do not understand well how QgsGdalProvider::readBlock() deals with the resulting values. Why are the results stored as char * and not double???
double GDALRasterBand::GetScale ( int * pbSuccess = NULL ) [virtual]
Fetch the raster value scale.
This value (in combination with the GetOffset() value) is used to transform raw pixel values into the units returned by GetUnits(). For example this might be used to store elevations in GUInt16 bands with a precision of 0.1, and starting from -100.
Units value = (raw value * scale) + offset