Cloud mask - SNAP sentinel 2

hi all,

How do I do a cloud mask on a sentinel 2 image?

also should this be done before or after atmospheric correction?

1 Like

the sen2cor tool has a scene classification mode which automatically creates cloud pixels:
http://step.esa.int/main/third-party-plugins-2/sen2cor/

The tool performs atmospheric correction and creates a classified image.

You could use also IdePix module included in SNAP, it works on L1C TOA S2 data without applying atmospheric correction.
The Idepix Processor provides a pixel classification into properties such as clear/cloudy, land/water, snow, ice etc. The processing options/parameters as well as the underlying classification algorithms are instrument-dependent. The Idepix processor provided with the current SNAP version supports the Sentinel-2 MSI instrument as well as MODIS and Landsat-8.
You can find IdePix module under ‘Optical’ --> ‘Preprocessing’ --> ‘Masking’ --> ‘IdePix (Clouds, Land, Water, …)’ --> 'Sentinel-2 MSI’

1 Like

Hi ABraun,

thank you so much for your reply. So if I run the image through atmospheric correction in Sen2cor then does that get rid of the cloud automatically?

no. There is chance that smaller haze will be reduced but information below clouds is considered lost.

Source:
http://step.esa.int/thirdparties/sen2cor/2.3.1/[L2A-SUM]%20S2-PDGS-MPC-L2A-SUM%20[2.3.0].pdf (page 21)

1 Like

Hi Fabrizio,

thank you for your reply!

So If i run the L1C image through the idepix module and then through atmospheric correction, will the cloud cover be masked from the image?

Okay, I think I understand. It will visually get rid of some of the haze. Will it change the pixel values of the clouded areas?

Thank you for answering my questions

Hi,

Sen2Cor (for atmospheric correction) take as input only S2 original file and therefore if you apply IdePix you can not use Sen2Cor anymore.
If you intend to apply also atmospheric correction I suggest to take into consideration the post of ABraun

Regards,
Fabrizio

Hello. Would sen2three be helpful? Seems like you want cloud mask but also the resulting holes filled in. I think sen2three does this.

‘Sen2Three is a level 3 processor for the Spatio-Temporal Synthesis of bottom of atmosphere corrected Sentinel-2 level 2a images, as they are generated by the Sen2Cor application. Sen2Three takes time series of level 2a images of certain geographical areas (tiles) as input and generates a synthetic output image by replacing step by step all “bad” pixels of previous input images with the collocated “good” pixels of scenes following in time.’
http://step.esa.int/main/third-party-plugins-2/sen2three/

Hi Fabrizio, thanks for the information. Unfortunately, in my case I am getting this error

Could you please explain to resolve the issue?

You should resample the S2 data (Raster > Geometric Operations > Resampling) to one target resolution (10m, 20m or 60m).

1 Like

Its not clear to me!!

Sentinel-2 has 14 bands, but they do not have the same spatial resolution:
https://earth.esa.int/web/sentinel/user-guides/sentinel-2-msi/resolutions/spatial

Image source

If you want to work with Sentinel-2 data as a stack in SNAP you have to bring the into one common resolution. This is called resampling.
https://senbox.atlassian.net/wiki/display/SNAP/Resampling+notifications

3 Likes

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