Cloud masking using band math in graph builder for L2A


I converted sentinel 2 images from L1C to L2A using SNAP and now would like to remove the cloud from the image using band math expression in graph builder. Can anyone tell me the expression that I can use to get an image without the clouds?? I am mainly confused with the mathematical expression to be used in band math.
Thank you.


the only thing that you can do is to remove all pixels which were identified as clouds in the automated scene classification done by snap. You can do that in the band properties by creating a valid pixel expression. sen2cor already produced cloud masks which you can use for this, just make sure to display the maks in the band maths as well. Similar as here: Export for unwrapping
I tried to give an example here in another context: Cloud related problem

Some more topics on cloud masking can be found via the search function:“Cloud masking”


Thanks a lot but again the expression is said to be invalid. Can I apply the same mask to all the bands available in the image?


Maybe you haven’t selected an L2A product as source in the read operator? This would explain why it says invalid.
Or you haven’t selected it as the first step. It seems that the BandMath dialog does not detect the changes in the read operation properly.
And I think that you actually want to use || and not &. You want to set 1 if the value is either 4 or 5, right?


Thank you. But can we use or instead for this operation?


Yes, or should work too, instead of ||


Thanks a lot …