Sen2cor and python module

I have installed the last release of Sen2Cor in my windows system , including it in the Anaconda environment so that now sen2cor is also set as a python package for python.
Currently Sen2Cor can run only if launched in the command window, but is it possible to import sen2cor as a python library in aa script and to use it in this way:

a = sen2cor(arguments)

where among the arguments there is for example an object of class Product from the snappy module?

It would be useful to use it in a processing chain, and having a Product as an object, instead of running sen2cor only in the command window

1 Like

If sen2Cor is properly installed it should be possible to use GPF to invoke it, as any other operator.
The call would be something like:
GPF.createProduct('Sen2Cor', ...)

1 Like

Hello Antonio,

Why would you need it as an object instead? I run sen2cor in python as following.

import os
cmd = ‘L2A_Process --resolution {} {}’.format(resolution,path_L1C)
os.system(cmd)

Best,
Andreas

I will try then…it works properly when launched from command window, I have never tried the other way…
Thanks!!

because I want to create some processing chain starting from an S2 product. So imagine you have a S2 product, you resample it, then you process it with sen2cor, then you subset it. I would like to do it with a Python script, without creatiing intermediate products as it happens if you run sen2cor in the command line…
I hope I have been clear about my idea :slight_smile:

Do you know that you can do all this also from the command line without Python. gpt and the graphs are designed for doing exactly this.

I know about the graphs even if I have never used them yet. But I would be interested in getting everything working coherently in Python. I am curious about getting a pipeline starting from a L-1 product up to some particular processing of the L-2 version.

I´m interested in such a process chain too. I would need to generate a script of several functions (modules in the GUI) in order to run it several times or to use it in other geographical areas.
From L1 to L2, including resampling, radiometric corrections, spectral indices, etc. Such chain involves certainly several operators (e.g., SEN2COR) and others.
Are there any codes repositories already available?
Sure someone will have already addressed this?
Thanks

In this thread is spoken about such chain and multiple operations invoked from python.

thankssss
hard to shifting from GUI to codes…

Hi all,

Is there any updates on the queries on this trend?

I’m planning also to do a process-chain script using Python from installation to L2A_Processing.

Your replies are appreciated!

Thanks!

Hi Tklom,

I’m also developing the process chain from downloading the L1c data to get the processed L2A data. How about your process chain? Have you make it work? Maybe we can share some ideas.

Cheers,
Steve