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

Added by Etienne Tourigny over 12 years ago. Updated about 10 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Rasters
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

Description

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???

From the page http://www.gdal.org/classGDALRasterBand.html#94f689e571b963cf8d35989b60269d1e

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

era40-t2.tif (22.1 KB) Etienne Tourigny, 2011-10-15 05:10 PM

era40-t2.nc (22.1 KB) Etienne Tourigny, 2011-10-15 05:10 PM

History

#1 Updated by Giovanni Manghi over 12 years ago

  • Target version set to Version 1.7.4

#2 Updated by Paolo Cavallini about 12 years ago

  • Crashes QGIS or corrupts data set to No
  • Affected QGIS version set to master
  • Target version changed from Version 1.7.4 to Version 1.8.0

#3 Updated by Paolo Cavallini over 11 years ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

#4 Updated by René-Luc ReLuc about 10 years ago

  • Target version changed from Version 2.0.0 to Version 2.4

I open a new pull request for this https://github.com/qgis/QGIS/pull/1252

#5 Updated by Etienne Tourigny about 10 years ago

  • Parent task set to #8417
  • Status changed from Open to Closed

closing as duplicate of #8417

Also available in: Atom PDF