0

I am trying to extract certain values from a raster image in order to create a new raster which should then only contain the specified values. I have a single band raster showing forest loss from 2000 to 2017. Pixel values range from 0 to 17, and correspond to the year in which the loss occurred. I am using the raster calculator with an expression such as:

"ForestLoss@1" = 11

It sort of works, but the output raster switches all the original pixel values to 1, and saves all of the other cells from the original raster as 0.

My hope was to have a new raster with only the cells that were originally 11 being retained.

  • A true/false expression evaluates to 1 when true and 0 when false. – csk Aug 3 '18 at 22:13
1

The result is 1 and 0, so use in Raster Calculator as:

("ForestLoss@1" = 11) * "ForestLoss@1"

And output will be 0's and 11's. So to delete 0's use GDAL Translate to set NA value:

enter image description here

With SAGA Raster Calculator you can do the same in one step. Use:

ifelse(eq(a,11), a, 0/0)

As:

enter image description here

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.