3

I have a raster dataset with pixel values ranging between 1 and 255. I would like to set 5-255 to 5 and leave pixels with 1,2,3,4 value in QGIS.

I know I can use the raster calculator (raster >=5)* 5, however, it classifies 5-255 values to 5 but also sets 1,2,3,4 value to 0. What should I do to avoid changing the values between 1 and 4?

2 Answers 2

8

Use Raster Calculator with an if-condition, available since QGIS 3.22, with this expression:

if ("raster@1" >= 5 , 5, "raster@1")
5

One tool you can use in QGIS is Reclassify by Table. Your table should look like this: Reclassification table where values from 1 to 1 become 1, values from 2 to 2 become 2, values from 3 to 3 become 3, values from 4 to 4 become 4, and values from 5 to 255 become 5.

1
  • 1
    Thanks @ChloeG for reminding this tool.
    – Sher
    Mar 20, 2023 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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