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.