[GIS] Calculating the difference between two grids in percent with QGIS

gdalmap-algebraqgisrasterraster-calculator

I'm using the QGIS GDAL Raster Calculator to get the difference in percent between two grids.

Grid A contains an integer, and grid B contains an integer which may be the same as or larger than the corresponding cell in grid A. They are geographically identical (in terms of cell size, extent etc).

So in the raster calculator I use this formula:

((B-A)/A)*100

…expecting a percent value in the created raster showing the difference in percent between raster A and B.

But the created raster is almost completely zeroes, except for a few places containing 100% values (they do not correspond with my manual control samples). I've chosen Int32 as the datatype for the created raster (I don't need more precision than whole percent).

Is the formula incorrect for what I'm trying to do, or have I missed something else?

Best Answer

Your results give the impression that when you are using integers in division, the result is also an integer (0 or 1).

Can you change the datatype of the input grid A or B to float?

If changing datatypes is a problem, another option could be to change the equation like this:

(((B-A)*100)/A)
Related Question