Raster math

how can I do conditional raster math. I want to replace masked pixel values with new values from another image. when i enter the following function it returns only the original masked image with no changes. who can help me


.

The expression is correct in general. Maybe the condition needs to be adapted.
Have you processed the data? Do you see zero as value in the Pixel Info View for the pixels you want to replace?
Can you show the Information Window for the band? Like this one:

Thank you for the reply. the image is sentinel level 2A data and it is resampled to 10m. the information is as follows

The sentinel level 2A products contains pixels with value greater than 0 (0 means no data).
So, your expression may work when you apply an expression like if $1.B1 < 0.3 then 0 else $1.B1.

You might use for the condition the raw, unscaled value. This works probably better.

if $1.B1.raw==0 then $2.B1 else $1.B1

In addition, one issue is that SNAP tries to be smart and uses the valid pixel expressions of the input bands
If you create a virtual band, you can delete this from the properties dialog of the band.
If you say you don’t want to store the expression and keep the real data, then this is automatically applied. You could remove the valid-pixel expressions from the input

However, for such a task there is actually a dedicated tool available in SNAP.
The Mosaic tool, or the Multi-size Mosaic.
This should probably work better for you.

1 Like

Thank you very much it worked. i have changed the conditional raster to larger number by multiplying by 1000