How to give cloud value is Nan

I extracted S3A(OLCI) rtoa band from (output of C2RCC processor)
now I want to give cloud value is NAN and then Apply OC4ME algorithm to getting chlorophyll value

There are several ways of doing it.
You can create copies of the rtoa bands where the cloudy pixels are set to NaN.
Use the Band Maths with an if-else statement.

if c2rcc_flags.Cloud_risk then NaN else rtoa_6

Change the condition to your needs.

Or you can create a mask in the Mask Manager.

In your algorithm you can then use this mask as condition.

The OC4ME and the C2RCC NN chlorophyll values are calculated in the L2 standard from EUMETSAT. Maybe you can download it from CODA and merge with the C2RCC product to have all reflectance from both ACs

1 Like

Thanks, but I didnot do c2rcc now, this time I run S3 L1 data into icor after completion of process I opened band and seen strange value on land that could see in below images, now I need to give land value is nan, for how to do that?
What command I need to enter in bandmath to get Land NaN

How about if then NaN else Oa1 ?

Sorry I could not understand, Can you please make me further more clear about

The equation for the Band Maths. You can try:
if then NaN else Oa1
This way you get a new band.

As alternative you can open the properties of a band (right-click and select from the contect menu) and set as valid-pixel expression

In general I would recommend that you experiment with the Band Maths. This way you will learn most.

Thank you, I tried your command it give output land value as NaN… but Water pixel value are very strange like 80,78, but before bandmath water pixel look liked 0.0458 , 0.0589,

can we give NaN value from pixel based band math, because after running atmosphere correction all the land and cloud pixel value are same that value you can see previous image i shared Oa1
My view is If I give that pixel = NaN may be I will get land and cloud Value is NaN

The histogram looks similar to what you have posted in the other thread

Maybe you have used the uncorrected radiances and not the corrected reflectances.

I created mask then I try to create nan value
like this command

but command not passed

You try to create a mask. For a mask, the result of the expression needs to be boolean (true or false).
The CHL_X and NaN are not a boolean value.

The expression you have used can be used in the Band Maths to create a new band.

I tried to mask with range that you can see in the area red color, but How to set NaN and taking image out

One thing you cannot do in SNAP is to change the values of an existing band.
You can create a new one and change the values with the band maths.
You can then save/export the product.

After running ICOR there is no quality flag. Land ,cloud … here I have only 21 band iwith this band what expression need to apply to become land value NaN…
I have threshold value 10
i want to give the pixel value more than 10 =NaN
For this how to make expression in band math

Thank you

You can use the Mask Manager to create a new mask using a threshold on another band with the [x] function.

Thank you, I created new mask by fixing (min 0 0a3 max10) the file created in the name of new mask-1 The given value covered in red colour, I fixed limit and now how to make set other value NaN?

The mask is just masking the values but does not change them.
As said earlier, to set them to NaN you need to create a new band by the Band Maths. There you can use the created mask in the condition.
if mask_1 then NaN else Oa3

I also wonder why your values are between 0 and 10. After atmospheric correction, the reflectance values are usually between 0 and 1.

Yes I am too confused with apply value but now i understood how to do, and finally fix the land value NaN

I really happy… without you peoples it not possible, My hearty thanks to Marpet, Abruescas and others :innocent:

1 Like

hello dears
Now I know create new mask, bandmath in SNAP GUI…But i need to learn this process by using spyder python script, can you anyone suggest link to learn how to create new mask using python script…


It depends on where it is your starting point. If you are importing one image .dim to Python, flags are coded, so you have to decode them first. If you save your mask as a band, you can read it with rasterio, or envi directly.