Cloud cover removal using Python

Hi Everyone,

How to remove cloud cover and cloud shadow from Sentinel L2A (BOA) image using python scripting? or get cloud cover/shadow mask (.shp) using python?

Harsh L. Shah

You can use the IdePix for S2 data from Python.
Can idepix be called in snappy? - development / python - STEP Forum (

You need to install snappy beforehand.
Using SNAP in your Python programs - SNAP - Confluence (


Hi Marpet,

Thanks for reply. I will have a look on shared links.

Thanks again
Harsh L. Shah

Another option to invoke IdePix and other operators and graphs is to use snapista.
Introducing snapista, a GPT wrapper for Python - Show Room - STEP Forum (

In this case you don’t need snappy.

1 Like

Hi Marco,

Thanks for the reply. I have installed snappy using pip in python 3.7.

Now, I seek your help to process data (remove cloud/shadow/haze from bands). Is it possible for you to share steps?

Harsh L. Shah

Removing clouds/shadows and so on is not possible. This can only be detected.
Removing them is still a part of research and needs additional data, like SAR.
For example:

Regarding the usage of IdePix, I suggest that you first have a look at it by using the GUI and looking at the help.
Also, in the forum several threads can be found which are useful.

Yes, I am looking to detect clouds/shadows from images (bands). After installing snappy in python 3.7 when I tried to import ProductIO, it shows error.

“from snappy import ProductIO
ImportError: cannot import name ‘ProductIO’ from ‘snappy’”

Is there any step by step read me for the same?

There is only the guide I’ve already posted.
The error indicates that snappy is not yet correctly installed.
It can be sometimes tricky. That’s why I also referred to snapista. It is easier to use.

Please use either Python 3.5 or 3.6. If later versions are used the necessary jpy library needs to be built manually. I’ve added a note which is mentioning this in the documentation.