3

I'm trying to calculate four greenness indices using the GDAL calculator within the graphic modeler in QGIS 2.14.7 Essen.

The tool systematically crashes with a Windows message stating that Python has stopped for three of the indices. According to the result processing windows it is related to a division problem.

The indices are as follows:
GRVI=(green-red)/(green+red)
GCC=green/(red+green+blue)
VARI=(green-red)/(green+red-blue)
ExGC=2*Green-(red+blue)

The only index that doesn't make Python crash is the last one.

I have checked the raster and cannot find a single pixel with (red+green+blue)=0 or (red+green)=0, although there are a few with (green+red-blue)=0. Checking the results and comparing the values at single pixels, it seems that it is in fact a 0 in the numerator which is causing the problem, in the three indices. In fact, those pixels with (green+red-blue)=0 are set to inf., while those with a 0 in the numerator are set to nodata.

I don't understand why a 0 in the numerator should cause a nodata value, but I don't get either why this would be a problem for the calculation, as nodata values are common in many raster files.

I should also notice that my original raster is a 4-band (RGB+alpha) geotiff file (byte file with int8), which no data value defined. Before sending it to the calculator I clip it and get a smaller geotiff, which is Float32.

A final note: everything works smoothing when the raster calculator is accessed from the menu.

I provide below an image of the settings for calculating GCC

Dialog window as defined for one of the indices

Edit: new findings! If I set all output as temporal layers after the crashes most of the indices have been correctly done, but with those pixels with the numerator=0 as nodata. The exception is VARI, which appears as all NaN in the legend...and when trying to open its properties I get an Exception error. However, when I set a file name for each of the indices, all of them appear as nodata rasters (although no problem opening the properties this time).

Can someone can give me a hint?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.