3

I can’t figure out how to do this in QGIS. I tried gdal and SAGA raster calculator in QGIS. Here is the situation: I have two raster for the same area in the same projection with the same extent and the same resolution.

Raster A (has integer values from 1 to 5)

Raster B (has values from 1 to 7)

The calculation should do the following: if a cell in raster B is >= 3, make the cell for raster A + 1. So the result should be the whole raster A, but cell values in raster A where raster B is bigger than 3 should be +1. My formula so far (for GDAL):

((A*(A>=3))+(B>=3))+(A*(A<3))

But the result is missing all values lower then 3. Anyone any suggestions?

2
  • is this along the lines of what you're looking for?gis.stackexchange.com/questions/141305/…
    – Zipper1365
    Commented Feb 2, 2018 at 16:28
  • 2
    Not tested but maybe something like: (("RasterB@1" >= 3) * ("RasterA@1" + 1)) + (("RasterB@1" < 3) * "RasterA@1")
    – Joseph
    Commented Feb 2, 2018 at 16:35

1 Answer 1

2

As to the SAGA Raster calculator (QGIS Processing Toolbox | SAGA | Raster calculus | Raster calculator).

SAGA formula is:

ifelse(or(b > 3,  b = 3), a + 1, a)

A catch is that b >= 3 becomes OR(b>3, b=3). OR(x,y) returns true (1), if at least one of both x, y is true.

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.