Cloud mask - SNAP sentinel 2

I’ll show you the process:



I suspect about the Coordinate system, the weird thing is that this error appear in some images and not in other, when all the images where processed with the same batch process with the same parameters.

area all images from the same tile?

Because some tiles range over two UTM zones, thus some negative coordinates can occur.

No, not all the images are from the same tile.

Could you apply idepix individually to a couple of your image, these have error

Actually, the error happens because of the sun zenith.

i have done cloud mask for sentinel 2B L2A image in SNAP(Sen2Cor) by creating cloud mask for 10 m resolution using Band Maths for scl_cloud_high_proba, scl_cloud_medium_proba and scl_thin_cirrus separately. Now i want to replace the cloud mask areas by using another clear image as reference image. Could you tell me the process or steps to replace the cloud in SNAP- 6 version. thank you in advanced. i upload here only two separate cloud mask images

1 Like

If both, the cloudy and the clear reference scene, have the same extent and at the same location (same S2 tile) then you can also use Band Maths.

Use as expression the following:

IF (scl_cloud_high_proba  || scl_cloud_medium_proba || scl_thin_cirrus) THEN $2.B01 ELSE B01

If they don’t have the same extent then you would need to collocate them first. and then apply the expression.

But you can also do a mosaic.

1 Like

@marpet, Thank you so much for you help. I have done Mosaicing of cloudy sentinel 2B_L2A image. i have attached the cloud masking image here. please tell me how can i replace the mask areas with reference image. Thank you in advance.

if both the masked and the reference image have the same pixel extent and size, you can replace the masked values in the band maths with an IF statement as demonstrated here: Replacing NaN with 3x3 average

@ABraun, Thank you for your response. My two images are same extent ( same tile number). i have attached the image here.

. In the picture, 2 no. image is cloudy, 3 no. image is clear image and 4 no. image that i have masked the cloud using Moasaicing option in SNAP 6. Now i want to replace the cloud mask areas from 4 no. image by 3 no. clear image. i do not want to replace with average values of around the NaN value areas. I exactly want to replace the cloudy areas by their corresponding clear areas. Otherwise, the my mapping result will not be good. Thank you so much

I understood that - the principle to replace the values is the same. Instead of the average raster you simply use image number 4 (I4). But you have to do this band by band:

IF I2_b1 == 0 THEN I4_b1 ELSE I1_b1
IF I2_b2 == 0 THEN I4_b2 ELSE I1_b2
IF I2_b3 == 0 THEN I4_b3 ELSE I1_b3

You can use the Band Maths as I said before. I attache some screenshots.
Maybe you don’t have enough images to replace all cloud pixels.

If you are not bound to the date you currently use. The S2GM service might be useful for you. For your region (53TLN) L2A data is only available from December 2018 onwards.

There is also Theia which is providing mosaics of Sentinel-2 but I think your region is also not available. (@OHagolle)

Thank you @marpet,
Yes, the region (53TLN) is not among the ones processed by Theia, but the softwares are available.

@shamimcaas: You will need to use MAJA to get L2A products, and then WASP to make the monthly syntheses.
To use MAJA :
To use WASP:

Both tools work on linux only. There are executable versions which are easy to install.

@ABraun,and @marpet Thank you all for your information.

@marpet, i have created Cloud mask band using band math given in picture(Cloud_mask). Then i have resampled the the S2B_MSIL2A image considering 10 m pixel size, not the reference band.

. After i have mosaiced the image cloud_Mask image (Mosaic) and i have got the cloud mask image given in picture. I have an clear image near date. Now i want replace the Could_mask areas by corresponding parts of clear image. could you tell me the steps, procedures or ways how will i replace the cloud areas. i have uploaded cloudy, cloud_mask image and clear image previous time. Thank you in advance.

What about my suggestion with the band maths above?

@ABraun, sorry, i can not run your Band math expression.

Could you Provide details with picture? Thank you so much.

@ABraun, could you tell me which image i will use? only mosaic? how will i use the clear image?

You use both the maskes image and the mosaic. Open the band maths and go to the advanced expression editor. You find a dropdown menu in the top where you can switch between both products and create the statement by selecting the bands as formulated above.

@ABraun, i am sorry to disturb you again, i can not do it. could you write the band math according to my image. i can not match your band math with my image. could you tell me which will be my target image? During Mosaic as target product there is no product option in Band math Expression Editor page. i am showing some pictures below.

. Thank you in advance.