4

I am trying to replace/update the raster pixel values of band '3' of a Land Cover Map to a new value of '24', but only where these pixels overlap with value '4' of another raster layer. How do I write this as an expression in the raster calculator? I am using QGIS.

2

When you want to change value x of RasterA-band3, on condition that the RasterB is 4, then:

(RasterA@3 = x) * (RasterB@1 = 4) * 24 +
(RasterA@3 > x) * RasterA@3 +
(RasterA@3 < x) * RasterA@3 

For instance if your target cell value is 1,

(RasterA@3 = 1) * (RasterB@1 = 4) * 24 +
(RasterA@3 > 1) * RasterA@3 +
(RasterA@3 < 1) * RasterA@3

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.