bogdanpalade

Change multiple band raster value

Discussion created by bogdanpalade on Nov 6, 2012
Latest reply on Nov 6, 2012 by mdenil
Dear all,

This is a recurrent problem that I have never managed to solve. If I have a RGB image (3 bands raster) and want to set its cell value to 0 only where all the three component bands have a specific value (lets say 150), how should I do it.

I can list each individual band:

B1 = raster/Band_1
B2 = raster/Band_2
B3 = raster/Band_3

But then, I do not know how to build my loop to get the exact condition.

I have tried something like this but it's wrong.




if B1 == 150:
    if B2 == 150:
        if B3 ==150:
            raster = 0


Can you give me a hint on how to proceed?

Thank you

Outcomes