S2Cloudless and Python


I am trying to implement in my Python Script the s2cloudless. I am using python 3.6.13 so I installed s2cloudless 1.5.0. I have some questions:

  1. Is it necessary to check for clouds after the initial scene classification?

  2. Why I cannot import the specific s2cloudless version? It gives an error about future annotations meaning it needs newer python version when in the documentation it says that 1.5.0 needs python >= 3.6.

Thank you in advance.

Hi, I asked my colleagues a bit, and we hope this helps.

  1. s2cloudless will classify input data into cloudy and cloudless pixels, based on specified cloud probability threshold and post-processing parameters. If desired it will also return the cloud probability mask (see this method).
    If you are talking about scene classification data, available in L2A data (calculated with Sen2Cor), then beware that the cloud masks available in there are different from s2cloudless (Sen2cor uses different algorithm). You can read more about comparison of s2cloudless and other cloud masking algorithms also in Cloud Mask Intercomparison eXercise (CMIX): An evaluation of cloud masking algorithms for Landsat 8 and Sentinel-2 - ScienceDirect
  2. Please check your sentinelhub version (a requirement of the s2cloudless). I suspect it is above 3.6.0. Sadly the new versions of sentinelhub only support Python 3.7 or higher. If you want a version that is guaranteed to support 3.6. you need to downgrade sentinelhub all the way down to 3.4.2 (you might get by with 3.5.2). However due to the changes to the SentinelHub service it is hard to guarantee everything will work as it should without the latest version. Unless you are restricted by the Python version I’d suggest upgrading Python.

Thank you for your quick response.

I am using data derived from sentinel-2. I read the paper that you suggested, but still my question remains. If the Scene Classification algorithm is efficient for a three-year-data product to eliminate every possible clouds using a median value perhaps?

Regarding s2cloudless, I already talked with my colleagues and it will be oh high priority.

Thank you in advance.

To eliminate every possible cloud several things have to be considered:

  • both s2cloudless and cloud masks from scene classification layer have their own false negatives. In this sense, you have to decide what is still acceptable.
  • tweaking the parameters of the s2cloudless, you can influence the amount of detected clouds with:
    • using lower cloud probability threshold for creating a cloud mask
    • increasing the dilation parameter (making cloud masks larger)

Both these tweaks will result in larger number of pixels classified as clouds, and often at the expense of cloudless pixels.

I cannot say much about the Scene Classification algorithm, but I am sure simple methods like a median value will not be sufficient to eliminate every possible cloud.