I'm trying to update some values of a raster based on another raster.

1st raster (A): landuse data (values from 10 to 240)

2nd raster (B): mask data (only nodata values and a given value, for example: 20)

Objective: for a given pixel, if Pixel A == 212 and Pixel B == 20, replace pixel A with pixel B value.

So, my 1st command is: B*(A==212). That works fine, I'm getting a raster with pixels that matches the objectives and with the new value.

I'm having problems with the second raster manipulation. I dont know how to get a new full raster with values updated.

Anyone have an idea of how I can do that in, if possible, only one math formula ?


the test yields either 1 (true) or 0 (false). So you can make an "and" by multiplying the results, and the othe cases using 1-(condition). Here ismy suggestion

B*(A==212)*(B==20) + A*(1-(A==212)*(B==20))

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.