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:


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

  • Try float(((B-A)/A)*100) based in the answer of eeroant.
    – xunilk
    Commented Oct 30, 2015 at 11:12
  • I tried it but only got a 0 in every cell as a result. No NoData values either.
    – hexamon
    Commented Oct 30, 2015 at 11:42

1 Answer 1


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:

  • I've tried this now, but the output raster comes out black, and when trying to open its properties in QGIS I get a Bad Allocation error.
    – hexamon
    Commented Oct 30, 2015 at 11:43
  • @hexamon: Can you try this another solution?
    – eeroant
    Commented Oct 30, 2015 at 12:16

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.