I have a land use layer which includes 36 different individual classes. Using the raster calculator I have been able to extract 1 of the different classes and make a new layer (landuse=[number of the land use class]). I want to put multiple of these classes together to create one layer e.g. a general forest layer, and tried using the AND function. This however is not working and only acknowledges the first number in the equation (e.g. landuse = 1 AND 2 AND 3) only the land use equivalent to 1 is produced. Does anyone have any ideas?
1 Answer
Currently your telling the calculator to include everything where landuse equals 1
and where 2
and where 3
. Now your old math teacher comes around the corner and asks "Three what? Bananas? Apples? Gas stations?"
After showing him (nicely) out the door you provide more details to your algorithm, e.g. landuse = 1 AND landuse = 2 AND landuse = 3
. While this might work out, your programming tutor strolls in and has a nervous breakdown, since basically you're looking for pixels where the landuse is 1, 2 and 3 at the same time.
You hand him a calming tea, seat him on the condo and return to your expression, replacing your ANDs
by ORs
, while also shortening it a bit: landuse = (1 OR 2 OR 3)
.
-
2And then someone versed in Boolean logic points out that
1 or 2 or 3
resolves toTrue
· and the expression tolanduse == 1
. This is the place for theIN
operator..– VinceJul 22, 2022 at 12:07 -
1@Vince I noticed that too, but @Erik's high reputation makes me think the raster calculator interprets
landuse = (1 OR 2 OR 3)
correctly as the equivalent of SQL'slanduse IN (1,2,3)
. The OP's original query parses as(landuse=1) OR 2 OR 3
, effectively confirming that non-zero zero constant are truthy Jul 22, 2022 at 12:16 -
landuse = 1 OR landuse = 2 OR landuse = 3
?IN
operator (field IN (1,2,3)
)IN
?