Cloud mask - SNAP sentinel 2

Hello!! appreciated StephP
After the fourth point I don’t understand you, you could be more specific. Thank you

Hello Abruescas
Thanks for your input, I would like to know what parameters I should use the idepix tool to remove the value of the pixels from the clouds in an S2A-Misilc image.

Thanks in advance.

How can i apply idepix to MODIS products

you first install it via the Plugins menu

Make sure you download MODIS L1B Calibrated Radiance products: https://search.earthdata.nasa.gov/search?q=MOD021

Then you apply IDEPIX

1 Like

Help!!
I have the following problem, I already applied cloud mask with idepix to sentinel 2 and modis, remove the value of the pixels corresponding to the clouds using the Band-Math tool, save in the default Snap format (Beam-Dimap) but when opening them In the Sig Qgis tool the cloud masks do not appear, and the pixels of the clouds are still there, it is as if nothing had been done. I tried to save and use another format I tried with Geo-Tiff format but I only get one file with the information of all the bands, and I want the bands to be individual (one file for each band) also that the pixels of the clouds do not interfere with the other pixels and be able to visualize the results in another Sig tool to verify.

I appreciate any input.

QGIS cannot read the valid-pixel expressions or masks which belong to a BEAM DIMAP product, they are only used in SNAP. For QGIS the raster is simply a matrix with values. GeoTiff also doesn’t store such metadata.

If you want to permanently remove these values, you have to replace the raster values, for example in the band maths.

IF band_1 == mask THEN 0 ELSE band_1

This replaces any pixel within the mask by zero . If you then open the raster in QGIS you can set 0 as the NoData value (in the transparency tab): S1 tile in QGIS: Zero values

1 Like

Thank you very much Abraun, it has been very helpful

I have resampled the image to 20 m, but if I apply idepix tool to masking cloud. it gives me the following error:

image

do you have solution about that? thanks before!

Some time ago this has been reported for a different use case.
Please have a look at this issue ticket (SNAP-561). Especially at the comment below.

Good night Sir,

Is the similar procedure for Sentinel 2A Level-2A?
Atmospheric correction applied to Top-Of-Atmosphere (TOA) Level-1C. So, the Level-2A output is an orthoimage Bottom-Of-Atmosphere (BOA) corrected reflectance product(https://sentinel.esa.int/web/sentinel/user-guides/sentinel-2-msi/processing-levels/level-2). The IdePex Sentinel 2 MSI have an option for write ToA reflectance to the target product and other option for write feature values to the target product. What to do in this case?
Thank you for your valuable response.

IdePix doesn’t work on L2A data. You can run it on L1C and then merge the result with the L2A data.
Or you can use the cloud mask of the L2A product directly.

1 Like

Thank you Sir,
Do you have a link of a tutorial for cloud mask the L2A using the second option? Grateful for your advise.

You can use the masks provided with the data.
image

For example in the valid-pixel expression:
image
image

Maybe this is also of interest for you:

1 Like

Sir I do not understand. I want to do this with SNAP. I did it before in Google Earth Engine with level 1C. I am just no familiar with this software. I used the option in gis.stackexchange.com as you advised using a virtual band I created in the mask manager. I got this. What is my next step to get the bands than I need free of cloud cover?

Please.

If you have the cloud mask it depends on your final goal what will be the next step.

For an RGB image with out clouds you can modify the valid expression for each of the used bands.
For example:
B2.raw > 0 && !scl_cloud_medium_proba && !scl_cloud_high_proba
And the same for B3 and B4.

Image before:

Image after:


The borders of the clouds are still visible, because the cloud detection is not perfect and I didn’t try hard.

1 Like

Thank you Sir,
My goal is to computer 4 spectral indexes:
The Modification of the Normalised Difference Vegetation Index
The Normalised Difference Vegetation Index (NDVI)
The Normalised Difference Bareness Index (NDBal) and
The Normalised Difference Built-up Index (NDBI).
At the end I have to merge all the layers together and compute the unsupervised classification K-Mean for a bauxite mine site. So I need the the SWIR band Band 11 to be resampling to 10m resolution I also need a VNIR band, in this case I can used Band 8.

Grateful for your advise,
Susy

Then do the modification for band B11 and B8.

B8.raw > 0 && !scl_cloud_medium_proba && !scl_cloud_high_proba

B11.raw > 0 && !scl_cloud_medium_proba && !scl_cloud_high_proba

Or do it in the NDVI expression when using the Band Maths:
if (scl_cloud_medium_proba || scl_cloud_high_proba) then NaN else ((B8 - B11) / (B8 + B11))

1 Like

Thank you Sir. You are my only help in this entire country.

Good night Mr Marpet,
I did the cloud masking for each bands. I have to do something else with the image in the future.
Please find attached the results. I want to see the free cloud cover image in QGIS or SAGA GIS as I used to do with GEE images. When I load the raster image into QGIS after the cloud masking. The clouds still there?



Grateful for your comments,
Susy

Yes, when exporting the bands with such expressions it gets probably lost. Other applications don’t know it.
But you can create new bands which you can then export.

For the RGB channels at the example of B4 (red):
red = if scl_cloud_medium_proba || scl_cloud_high_proba then NaN else B4

image
Make sure to disable the virtual option.