1

I opened a sub-dataset of an HDF file (NDVI layer of MODIS HDF file) in QGIS, but pixel values are beyond the valid range (-2000,10000). I see many pixels way less than -2000 and way over than 10000. There is something wrong here.

When I read layer into numpy array in Python, all pixel values between valid range, so everything is expected.

you can download the file here, MODIS hdf file Extract the first layer, NDVI, no=0.

enter image description here

information about QGIS version on Ubuntu 12.04 LTS: QGIS version 2.8.1-Wien QGIS code revision exported Compiled against Qt 4.8.1 Running against Qt 4.8.1 Compiled against GDAL/OGR 1.10.0 Running against GDAL/OGR 1.10.0 Compiled against GEOS 3.4.2-CAPI-1.8.2 Running against GEOS 3.4.2-CAPI-1.8.2 r3921 PostgreSQL Client Version 9.1.15 SpatiaLite Version 4.1.1 QWT Version 5.2.2 PROJ.4 Version 480 QScintilla2 Version 2.6.1

7
  • I can replicate the issue on QGIS 2.8.2 on Windows 8.
    – PKG
    Commented Aug 20, 2015 at 6:03
  • 1 The opened file, when multiplied by the scale factor (0.0001) in raster calculator, gives the right/expected results. 2 gdalwarp converts the hdf file to geotif as expected (so no problem with the file). 3 Possibly QGIS is reading some meta-data from hdf file and displaying with additional scale factor.
    – PKG
    Commented Aug 20, 2015 at 6:09
  • how do we report this issue to the guys who develop QGIS so that they can fix it? Such basic thing shouldn't be a problem, in the first place.
    – aly
    Commented Aug 21, 2015 at 1:40
  • 1
    Is the scale factor 10000 (as in the metadata) or 0.0001? hdfgroup.org/training/HDFtraining/UsersGuide/SDS_SD.fm9.html defines Value by which each array value is to be multipliedso the metadata entry seems to be wrong.
    – AndreJ
    Commented Aug 21, 2015 at 5:41
  • See hub.qgis.org/issues/13248 for any progress on the developers side.
    – AndreJ
    Commented Aug 21, 2015 at 5:50

1 Answer 1

1

In the questions screenshot, it is the HDFview software that reports the extent in 16-bit integer. QGIS itself shows a scaled extent of -2.e+07 to 9.98e+07. Since NDVI is defined between -1 and 1, it scales wrong. The values have to be divided (not multiplied) by 10000, and should be between -0.2 and 1.

If you use gdalwarp to reproject the raster to something useful, the scale factor will not be applied:

enter image description here

So you have to keep an eye on it and apply the scale factor manually if necessary.

1
  • 1
    HDFview software lets you see the metadata, it doesn't report anything it creates. The metadata says the valid range is between -2000 and 10000. NDVI takes values between -1 and 1. The scale factor is 10000, so metadata is correct. However, QGIS displays the raster values wrong. When you open the dataset and read it into an array like this gdal.Open(NDVI dataset).ReadAsArray(), you will see that values are between -2000 and 10000. QGIS is doing something wrong here. It is safe to say there is a bug in QGIS when displaying 16bit integer arrays.
    – aly
    Commented Aug 21, 2015 at 1:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.