I have a crop data raster layer in QGIS with one band with values from 10 to 230.
I have written an expression in the Raster Calculator to keep only a number of values (e.g. when = 145 OR when = to 146, etc..
This works but the resulting layer has 0 values for areas that did not satisfy the expression and 1's for areas that did. As a result, I appear to have lost the original raster values which indicate crop types.
Am I doing this wrong or maybe there's another way to filter that will keep my original values?
Best Answer
If you use QGIS 3.22 or later, you have the new conditional
if
in raster calculator:For older versions, use:
I would not advice using something like
"RASTER@1" = 145 or "RASTER@1" = 146
: probably pixel values will not match exactly integers (145.00, 146.00), but be rather like 145.7 and using this expression, it will not find anything.