I have two rasters with the same extent, resolution, and projection, let's say raster A & B. What I want to do is something like this:
IF A = 3 OR A = 11 THEN A+B
ELSE B
How can I do such a thing with a raster calculator?
Try this syntax:
(A@1 = 3 + A@1 = 11)* A@1 + B@1
@1
means the first band of the rasterA@1 = 3
returns 1
(TRUE) if A is 3(A@1 = 3 + A@1 = 11)
part returns 1
. Otherwise it returns 0
.A@1 = 3
and A@1 = 11
return 0
. Then the overall expression becomes 0 * A + B
and ends with B
.