Cloud mask - SNAP sentinel 2

Yeah man I know that, I was expecting that it would ask for specific bands in my case I am only concerned about B2-B4 and B8 (10m). However, I started the resampling as you have suggested.

what operation did you execute?

For resampling what parameters shall I fix??

Okay let me elaborate my intention. I have to use RGBNIR bands for NDVI assessment and the problem is in tropical region its always covered with clouds. Could you please enlighten me step by step to get the cleaned image with true surface reflectance values?

I would really appreciate that. Thank you!

to get reflectance values you need to run sen2cor.
http://step.esa.int/main/third-party-plugins-2/sen2cor/

This tool gives you corrected reflectances but it does not remove thick clouds.

For the resampling, choose whatever resolution you need. Can’t tell you what’s best for your case :slight_smile:

Okay thank you for your help :slight_smile:

Hi ABraun

how to I remove thick clouds?

My image has been atmospheric corrected in sen2cor and resampled after.

raster> mask>land/sea mask> under parameters tab: from drop down select a cloud mask , click ‘run’.
but the output is just a black image. Do you have any suggestions?

Thank you

you could also try to define the valid pixel expression in the band properties. Something like “cloud_band == 0”)

Before

After

4 Likes

You absolute genius ! Thank you so much. I have been trying to figure this out for months. So if I export these bands now, will these cloud masks still apply?

2 Likes

Haven’t tested it but it would be worth a try.

If this doesn’t work: Have you tried checking “invert vector” in the land/sea mask operator?

Hello,
I have an output of Sen2Cor and I want to get rid of my cloud pixels.
I resampled the Sen2Cor output to have 60 m res for all bands. Then, in mask manager, I created a union of the cloud masks (high, medium, and low probability).
I tried Land/Sea Mask, use vector as mask, and to use union mask, I get the attached error. Is there a better way to do what I need to do? Am I doing something wrong here?

Hi,

I also want to create a cloud cover mask but I’m failing.
I have created a custom mask on the Band B1 that mask clouds with B1>0.19. Then I use the raster> mask>land/sea mask> under parameters tab: from drop down I selected the cloud mask I just created and saved the image as a GeoTIff. The script runs but when opening the GeoTiff in QGIS it return a black image with only nan values.
When running the same script but using the built-in opaque_cloud mask(10m) and the band B4, it works properly.

If I save as a BEAM-DIMAP it works, but it fails if I try to save as GeoTiff-BigTiff or simply GeoTif I get the following error message:


I am working with a product with only 1 band so I don’t understand what is going on here…

I then tried to save the BEAM-DIMAP product created as GeoTiff but it still create a black image with nan only.

Thanks!

try this.

Raster > Subset

Select yes and run without any change.
Should be done in about one second

Open your your new (virtual) product > File > Export > GeoTiff (not GeoTiff/ BigTiff)
There select “Subset…” and choose your desired band in “band subset”.

Worked for me. Please also see my thoughts on virtual resampling:

Great, it worked thanks a lot!!
I first resampled then masked and export product. It also now works directly when applying the mask to save as Geotiff.

Now my problem is that the masked area (in white on the right) in the product/Geotiff created is much smaller than the actually mask on the initial product (in red on the left)

Where could that be coming from?

What values do the red (masked) areas have before exporting?
Could it be useful to first convert the Mask to Integer?
Raster > Data conversion > Convert datatype

The mask is set to B1>0.19.
I tried the data conversion but the mask doesn’t show up in the list… I can see only the built-in masks.

I found a solution by creating a new layer based on the mask using band maths and then applying the mask again on that band saving as GeoTiff.

1 Like

Hello,
I m using S2-L2A product.
I m interested on vegetation and bare soil only, and I d mask (set to NaN) the other classes.
How can I do that with all the bands together. With Band Math, I have to process one band a time.
Also, for filtering, I would filter all the band in the same time.
Thanks

That’s the way you have to do it. Use Band Math on each band. You can also create a graph XML file and use it on the command line.
You could also change the valid-pixel expression for each of the bands (select properties from the context menu of a band).
On the command line the Image-Filter operator could be used.

gpt Image-Filter -h

@marpet

Is it possible to calculate NDVI for L2A product using Band Math and on newly created NDVI band use Valid-Pixel Expression, for example, sci_high_cloud_proba == 0 (Pic.1) where High cloud probability pixels are given NaN values for NDVI (Pic.2)
Thank You in advance


What does it do? Should that be clear all the cloud on the map?We need a clear viewon the map so that we can compute NDWI and FAPAR.