I like to evaluate the following expression in the QGIS Raster Calculator: IF
ELSEIF(A = 1, 1, ELSEIF((B = 1 OR B = 2), 3, ELSEIF((C = 1 OR C = 2), 4, ELSEIF(D = 1, 5, DEM))))
I tried the following expression in the Raster Calculator Console:
("A"=1)*1 + ("B" = 1)*3 +("B" = 2)*3 + ("C" = 1)*4 + ("C" = 2)*4 + ("D" = 1)*5 + "DEM"
The idea is to get values from 1 - 5 if some of the first conditional statements are fullfilled when evaluating for the rasters that are not the Digital Elevation Model, if any of those conditions are not fullfilled then it should get the value of the Digital Elevation Model. However when I run the calculation I get weird results that seems to be the sum of values in the Digital Elevation Model and some of the rasters.
What is the logic when using the raster calculator in QGIS to perform nested conditional map algebra?
("A" != 1)*(following terms)
and so on, but it will be an awfully long syntax. Why don't you use ifelse() function from SAGA Raster Calculator (in the Processing Toolbox)?a, b, c, d...
org1, g2, g3, g4...
according to the order they were supplied in the layer selection window. In this case, something likeifelse(a=1, 1, ifelse(or(b=1, b=2) ,3, .........))
.