Sentinel 2 from ESA satellite is sensitive to clouds when producing images. It is important to generate a cloud mask layer to avoid bad calculations during image processings.

This post is written to highlight the some delaults of cloud mask algorithm from ESA (sen2cor) as shown on the following example.

RGB of the 31UCP tile on the 2021-05-03

On the above image it is clear that there are clouds masking the ground, cloud shadows are more difficult to discern.

Black polylines indicate clouds and orange line cloud shadows
NIRGB composite image

By using a composite image and replacing the red band by the near infra red band, cloud shadow is more visible.

The cloud shadow detection is a quite difficult problem because, on the ground, the distance between the shadow and the cloud depend on the cloud altitude, increasing with cloud height and the inverse sun angle (during winter sun angle is around 20° so cloud shadow footprint will be far from the cloud footprint), Thus, defining a security perimeter around the cloud to avoid shadow problems is quite impossible. Some times the shadow is distant from the cloud footprint by several kilometers and sometimes is jointing the cloud footprint. Sen2cor is planned to take all these elements in consideration, but, unfortunately, with a lack of accuracy.

Sen2cor cloud maks corresponding to the above image, colors classes are indicated below. The shadow areas are too small.
On the other hand, the non vegetated fields are correctly detected (Yellow class)

As shown on above image, cloud shadow id not well detected by the algorithm, which is visble when zooming on a field:

Zoom on a field with cloud shadow
and the corresponding cloud mask from Sen2cor green color indicating crop vegetation
Cloud shadow generate a miscalculation in leaf area index


As a complement of Sen2cor which is nethertheless efficient and it out of question to let it down, a decision tree regression model was developped to focus on clouds and cloud shadow which produced the following results:

The NIR/G/B image with clouds and shadows
and the decision tree cloud and shadow mask (in maroon)
Compared above with sen2cor cloud mask,


Clearly, using the decision tree help in shadow detection by discarding dark pixels using the NIR band and setting a thresold.

The two masks will be used in superposition to discard bad pixels, it will be interesting to test other algorithms like Fmask and optram model, also some convolutional neural network could be tested as, like regression decision trees, they are regression and classification systems.