Issue with installation of sen2cor 2.3.1 on Ubuntu 16.04 (and other Linux distributions)

I have successfully installed anaconda and sen2cor 2.3.1 in a docker image, running Ubuntu 16.04. I have followed the instructions for properly setting my environment variables, and have gotten to the point where I am trying to process surface reflectance from source files downloaded from Google. However, I am getting the following messages when running L2A_Process:

root@0a916b56fde4:~/temp# L2A_Process S2A_MSIL1C_20170216T102101_N0204_R065_T33UUP_20170216T102204.SAFE

Sentinel-2 Level 2A Processor (Sen2Cor), 2.3.1, created: 2017.02.03 started …
Syntax error in metadata, see report file for details.
Parsing error:
Schema file: L2A_CAL_AC_GIPP.xsd
Details: Element ‘wavelength’, attribute ‘c0’: ‘’ is not a valid value of the local atomic type. (line 0)
Syntax error in metadata, see report file for details.
Parsing error:
Schema file: L2A_GIPP.xsd
Details: Element ‘PSD_Scheme’, attribute ‘PSD_Version’: [facet ‘length’] The value ‘’ has a length of ‘0’; this differs from the allowed length of ‘2’. (line 0)

The granule I’m attempting to process comes from this link, hosted by Google:

https://console.cloud.google.com/storage/browser/gcp-public-data-sentinel-2/tiles/44/Q/KM/S2A_MSIL1C_20170216T051901_N0204_R062_T44QKM_20170216T052242.SAFE/

Is there something wrong with the way I installed sen2cor, or do I need to format the data from Google in a specific way? Before the product change on December 7th, I was originally using sen2cor on scenes from AWS with great results, so gettings things working again would be fantastic.

Thank you for any help!

I’m also having problems with this data from google cloud. In my case I simply get:

“Sentinel-2 Level 2A Processor (Sen2Cor), 2.3.1, created: 2017.02.03 started …”

and nothing happens. :confused:

I just want to follow up with the exact steps I took to install sen2cor, as I believe it might be an installation error from my investigating. Here they are:

Creating the docker container:

sudo docker pull ubuntu:16.04
sudo docker run -itd --name sentinel_sr -t ubuntu:16.04 bash
sudo docker exec -it sentinel_sr bash

Setting up sen2cor inside the container

apt-get update
apt-get install --assume-yes wget bzip2
wget “https://repo.continuum.io/archive/Anaconda2-4.3.0-Linux-x86_64.sh
bash Anaconda2-4.3.0-Linux-x86_64.sh

echo ‘export PATH="/root/anaconda2/bin:$PATH"’ >> /root/.bashrc
exec -l $SHELL

wget http://step.esa.int/thirdparties/sen2cor/2.3.1/sen2cor-2.3.1.tar.gz
tar -xvzf sen2cor-2.3.1.tar.gz
rm sen2cor-2.3.1.tar.gz
cd sen2cor-2.3.1
python setup.py install

echo “source /root/sen2cor/L2A_Bashrc” >> /root/.bashrc
exec -l $SHELL

Hello,
I have the exact same problem. To spare you some time and pain, I build and run several docker images. (Took me days!!)
I tried to build and run the following images (the same way you did):
Ubuntu:16.06 - Anaconda4.3.0 - Sen2Cor2.3.1
Ubuntu:14.04 - Anaconda4.3.0 - Sen2Cor2.3.1
Ubuntu:14.04 - Anaconda4.2.0 - Sen2Cor2.3.0
Debian - Anaconda4.3.0 - Sen2Cor2.3.1
CentOs - Anaconda4.3.0 - Sen2Cor2.3.1

I also change the installation folder from /root/sen2cor to /opt/sen2cor to avoid permission problems.

I finally installed Sen2Cor from the “official” Anaconda docker image available here:
https://hub.docker.com/r/continuumio/anaconda/ (4.3.0 and 4.2.0)
I then installed sen2cor2.3.1 and 2.3.0.

I tried to trick docker and sen2cor by building an image with non root user installer but nothing changed.

And I tried to launch L2A_Process with images from PEPS platform :
https://peps.cnes.fr/rocket/#/
both new format:
S2A_MSIL1C_20170126T105321_N0204_R051_T31UCP_20170126T105612.SAFE
and older format :
S2A_OPER_PRD_MSIL1C_PDMC_20161130T185910_R094_V20161130T110422_20161130T110422.SAFE

I get the same message as you and at some point the process launches and everything seems to work fine but unfortunately, it takes a big step from ~11-14% to “100% : Application terminated successfully” but no process has been done at all in the resulting folder.

So I don’t think the problem comes from Google Cloud or the S2-image itself. I think we miss something in the installation but it remains a mystery to me because everything works fine with a local installation of Sen2Cor2.3.1 on Windows10. (I did not test a local install on Ubuntu OS)

Perhaps a change of subject “Sen2cor with data from Google Cloud Platform” will bring more help. :slight_smile:

Thanks Audrey! I’m glad I’m not the only one, and what you posted will definitely save me some time from banging my head against the wall. I really appreciate it.

I’ve changed the title to reflect that this is an issue with the sen2cor installation on Linux distributions, rather than being an issue with data from Google.

Hey everyone,

I’m excited to say that I’ve gotten everything working. It turns out that neither the official installation instructions or the data from Google was correct, without some minor changes.

For the installation, I had to explictly use an older version of Anaconda. The official documentation advises downloading the most recent version, but this is WRONG (at least for Linux). I hope someone responsible for writing that documentation is reading this, because that slight difference caused myself and others many extra hours of hopeless trials and errors.

When using data from Google, two folders must be created in the base directory: “AUX_DATA” and “HTML”. These must be present, even if you attempt to process just a single granule. I’m not sure why the processor cares about the presence of two entirely empty directories, but I would suggest the makers of sen2cor to remove this unnecessary dependency. It is especially annoying, because L2A_Process does NOT raise any errors about the missing directories.

Below, I will post the exact steps I took to create a working docker image:

sudo docker pull ubuntu:16.04
sudo docker run -itd --name sen2cor -t ubuntu:16.04 bash
sudo docker exec -it sen2cor bash

apt-get update
apt-get install --assume-yes wget bzip2
wget https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh

bash Anaconda2-4.2.0-Linux-x86_64.sh

echo ‘export PATH="/root/anaconda2/bin:$PATH"’ >> /root/.bashrc
exec -l $SHELL

wget http://step.esa.int/thirdparties/sen2cor/2.3.1/sen2cor-2.3.1.tar.gz
tar -xvzf sen2cor-2.3.1.tar.gz
rm sen2cor-2.3.1.tar.gz
cd sen2cor-2.3.1
python setup.py install

echo “source /root/sen2cor/L2A_Bashrc” >> /root/.bashrc
exec -l $SHELL

sudo docker commit sen2cor sen2cor

The main difference you’ll see above from what I originally posted in this thread, is the different Anaconda version which I found in continuum.io’s archives.

Now to process a granule retrieved from Google, here are the full instructions for installing gsutil:

curl https://sdk.cloud.google.com | bash
exec -l $SHELL
gcloud init

Then, to download and process a test granule:

gsutil -m cp -r gs://gcp-public-data-sentinel-2/tiles/33/U/UP/S2A_MSIL1C_20170216T102101_N0204_R065_T33UUP_20170216T102204.SAFE/ ./
cd S2A_MSIL1C_20170216T102101_N0204_R065_T33UUP_20170216T102204.SAFE
mkdir AUX_DATA HTML
L2A_Process ./

After processing, a new directory will be created in the same directory as the folder you processed, which will be named slightly differently:

S2A_MSIL1C_20170216T102101_N0204_R065_T33UUP_20170216T102204.SAFE (original)
S2A_MSIL2A_20170216T102101_N0204_R065_T33UUP_20170216T102204.SAFE (new)

If you look in the following path:

S2A_MSIL2A_20170216T102101_N0204_R065_T33UUP_20170216T102204.SAFE/GRANULE/L2A_T33UUP_A008642_20170216T102204/IMG_DATA/

You will see three directories, which contain your output at the three possible resolutions:

ls S2A_MSIL2A_20170216T102101_N0204_R065_T33UUP_20170216T102204.SAFE/GRANULE/L2A_T33UUP_A008642_20170216T102204/IMG_DATA/
R10m R20m R60m

That’s all you need. You can change the flags for L2A_Process as desired, to use different inputs and retrieve different outputs at desired resolutions.

EDIT: I should also point out that these instructions are for processing data which came after the Sentinel2 PSD update, affecting scenes starting on December 7th of 2016. I don’t need sen2cor for scenes before that date, but someone else may need to cross that bridge following the installation instructions I posted.

2 Likes

Along with my solution, I think it would be VERY useful for ESA to provide official docker images for sen2cor. There is no reason for people to be solving the same installation woes over and over again, if something like this can easily be containerized.

The instructions I posted above are valid for creating a working docker container with sen2cor 2.3.1, and would be very easy to
adapt into an official ESA docker image for sen2cor. If there is any interest, I would be willing to help in creating these images which would save many people a lot of time.

Cheers

Hi Vilos,

Thanks for this post! I tested the resulting docker image with PEPS granule, unfortunately, the problem stays unsolved for me. After 11%, the process take a big step to 100% : Application terminated successfully.
But almost nothing is processed. :frowning:

And I don’t think my image is altered because it is easily processed on sen2cor installed on windows.

I really don’t know how to solve this! I will post another issue on the forum.

Thanks again for this post.

Hi vilos92 and Audrey,
I had the same error (Syntax error in metadata …) with sen2cor 2.3.1 onto anaconda2 4.3.1 from ubuntu 14.04. Then as you mentioned I’ve installed sen2cor 2.3.1 onto anaconda2 4.2.0. I have no problem during installation. When I launched L2A_Process, sen2cor stops processing with no error description.
$ /usr/local/anaconda2/bin/L2A_Process --resolution=10 S2A_MSIL1C_20170303T074821_N0204_R135_T37PCS_20170303T080436.SAFE/
Sentinel-2 Level 2A Processor (Sen2Cor), 2.3.1, created: 2017.02.03 started …
$
I changed file name of sentinel-2 directory as previously described but I have the same problem.
Any suggestion ? Audrey, have you resolved your own but quite similar problem ?
Thanks.

I tried the latest docker image from vesnikos/sen2cor-docker on Windows 10 and beside the strange warnings/errors “Syntax error in metadata…” it works.
The image is based on Debian: 8.5 and includes miniconda (conda 4.3.21) and sen2cor 2.3.1.

Does anyone know how to get rid of these annoying warnings. It seems to be a Linux problem.

As vilos92 stated ESA should provide a official docker image for sen2cor. At the moment sen2cor installation and configuration is in most cases a nightmare.

I can confirm the issue on several distributions, and I can confirm that the solution by @vilos92 works. To sum it up: Anaconda 4.2.0 is necessary. Miniconda nor later Anaconda versions do not work properly out of the box. Specifically the main issue seems to be numpy, which needs to be 1.11 but later versions of Anaconda come with a newer version that doesn’t work properly. Miniconda doesn’t contain it to begin with, and even if I specifically install that version I get the constant errors about syntax in GIPP files.

Personally I have no need for a docker image, just proper installation instructions and dependency version numbers!

The metadata errors (Syntax error in metadata…) are caused by a bug in the libxml2 library version 2.9.4 installed by Anaconda 2.4.x (see sen2proc).
Just downgrade to libxml2 version 2.9.2 with the following command: conda install libxml2=2.9.2