Sen2cor on windows with gdal > 2.1.0

Sen2cor 2.3.1/Anaconda uses GDAL 2.1.0.

This version of GDAL does not have a driver for opening jp2000 files.

I need to use gdal >2.1.0 (for the jp2 drivers), but sen2cor has setup my User path variable GDAL_DATA to 2.1.0. Hence I cannot use other versions of GDAL from my ipython notebook. Even if i create a separate conda environment, and install GDAL 2.1.3, the notebook still picks up GDAL 2.1.0 ( because of user environment variable ).

If I upgrade GDAL will sen2cor work with GDAL >2.1.3 or 2.1.2?

Any work around for this?

Just noticed that you work on windows: here the gdaltools are located in “Your_Anaconda_installation_directory”\Library\bin, but the gereral principles are the same as described below. The question which tools are used are dependent on the arrangement of the path environment variable.

Let me first check whether I have understood your problem:

is it the case that you have a more recent version of the gdaltools installed (supporting JP2, somewhere outside of anaconda) which is now no longer reachable, after installation of anaconda, resp. the installation of the gdaltools inside of anaconda?

If yes, this is a problem of how anaconda sets it’s own environment: you will find (either in your .bashrc or in .profile) the following entry by anaconda:

//# added by Anaconda2 4.3.1 installer
export PATH=“/anaconda/bin:$PATH"

Anaconda installs all gdal tools in it’s own bin directory (see above) and this is the reason why your (more recent) gdal tools are no longer found afterwards. See:

$>which gdalinfo
//anaconda/bin/gdalinfo

but you can do the following:
//# this is my environment on OSX, your’s is dependent on where you installed the gdal tools:
$> export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH

afterwards, your own gdaltools are reachable again:

$> which gdalinfo
//# this is my environment, your’s is dependent on where you installed the gdal tools:
/Library/Frameworks/GDAL.framework/Programs/gdalinfo

Sen2Cor itself does not modify the path to use explicitly gdal 2.1. It completely depends on the Anaconda setup. You will even see that the path for GDAL_DATA inside of the L2A_Bashrc does not point to any GDAL version (as you state). It simply points to a directory in it’s own home environment where some essential geo-information is located, but this is completely local.

Sen2Cor also does not use the JP2 drivers: we had the same problems you describe (no support of JP2 for some gdal versions) - this is why we switched to the Glymur/OpenJPEG drivers. GDAL inside of Sen2Cor is only used for assembling the Digital Elevation Models, if this feature is selected via configuration but it is not used for en/decoding the JP2 images.

To upgrade GDAL inside of Anaconda, might be possible, but we do not support you in this issue, as it is not required by Sen2Cor and it apparently provokes some dependency problems (see Cannot read JPEG2000 anymore after installing SNAP). This might also be the reason why anaconda still installs the 2.1 baseline.

So for the workaround, we recommend that you set the PATH environment according to the GDAL Version you need (for your other purposes), as demonstrated above.

Hope this helps.

Thanks @umwilm that was a lot of information. I now understand how everything is setup. However I solved my problem by creating new environment and installing latest version of GDAL in it. I used this [conda install -c conda-forge gdal=2.1.3] to install GDAL. It is working perfectly fine now. I suppose conda is able to change the environment variable when I switch the conda environment.

I didn’t know STEP community switched to Glymur because GDAL was not working. I thought it had some additional functionalities that GDAL did’nt have.Thanks for the heads-up.

Dear @sinhavartika, Could you please show me the steps you followed, to install sen2cor 2.3.1 in new Anaconda 4.4.0 environment?