I am trying to implement sen2cor from python. The script i am using is

import snappy
from snappy import ProductIO
from snappy import GPF
from snappy import jpy
from snappy import HashMap
s=ProductIO.readProduct(‘C:\Program Files\snap\S2A_MSIL1C_20170910T090021_N0205_R007_T35SMD_20170910T090725.SAFE’)
HashMap = snappy.jpy.get_type(‘java.util.HashMap’)
parameters = HashMap()
parameters.put(‘resolution’, 60)
L2A_image = snappy.GPF.createProduct(‘Sen2Cor’, parameters, s)

I get the following error.
Traceback (most recent call last):
File “C:\Python34\doriforikes\”, line 32, in
L2A_image = snappy.GPF.createProduct(‘Sen2Cor’, parameters, s)
RuntimeError: org.esa.snap.core.gpf.OperatorException: Unknown operator ‘Sen2Cor’. Note that operator aliases are case sensitive.

Any ideas?

you should probably read this thread :

there are some recent updates and then probably someone like @marpet or @ramona_manda could tell you more if you need more help

1 Like

Did you tried the script in the post provided by Antonio? Did it worked? What version of SNAP and Sen2Cor do you have?

I tried the script but it didn t work.
Also i tried the combination snap beta 6 and sen2cor and it didn t work.

I tried to install sen2cor and now i get the following error C:\Python27\lib\site-packages\glymur\ UserWarning: Neither the openjp2 nor the openjpeg library could be loaded.
I already installed glymur library supposed to have openjpeg.

Any ideas?

Which version of sen2cor are you using? Is it version 2.4.0?
This brings its own python and should interfere with the one you already have installed. At least as far as I understood this.

I used version 2.4.0 and it worked through command line using this command in Python

Popen([‘cmd’, ‘/K’, ‘Sen2Cor-2.4.0-win64\L2A_Process E:\diplomatiki\S2A_MSIL1C_20170910T090021_N0205_R007_T35SMD_20170910T090725.SAFE --resolution=20’])

1 Like