Unit 20 - Sentinel downloader

There are plenty of libraries or tools which allows downloading Sentinel products from Copernicus Open Access Hub.

For GRASS GIS there is available i.sentinel Addon extension. It consists of fours GRASS modules:

Addons modules are not internal part of GRASS installation but can be easily installed by g.extension (Settings ‣ Addons extensions ‣ Install extension from addons). More about installing addons in Unit 17.

g.extension extension=i.sentinel
../_images/g-extension1.png

Fig. 111 Install i.sentinel GRASS Addon.

Note that i.sentinel.download requires also sentinelsat library to be installed.

Note

Sentinelsat library is already installed in the tailored virtual machine. If you need to install it on your machine, you can easily do that with

pip3 install sentinelsat

If you have not pip command, look how install it.

Let’s download suitable Sentinel products for our area of interest (AOI) and perform NDVI calculation as described in Unit 05 - Simple computation (implemented as a model in Unit 08 - Modeler or as a Python script in Unit 11 - PyGRASS scripting).

In our case AOI region is defined by Jena city region imported in Unit 03 - Data Management.

Sentinel-2 L2A products will be used to avoid need of computing atmospheric corrections at this moment. Let’s search for latest available product by i.sentinel.download. At first with -l flag given, just to print results, download procedure will be performed later. In order to search and download Sentinel products, you have to create an user account in Copernicus Open Access Hub, see manual page of i.sentinel.download module for details. Create a new file sentinel.txt containing two lines (username and password).

Note

To get username and password you need to register to the Copernicus Open Access Hub, see Register new account page for signing up.

i.sentinel.download -l map=jena_boundary producttype=S2MSI2A settings=sentinel.txt
12 Sentinel product(s) found
df8f6ae3-7391-44a2-a0a7-74e98e4ef993 ... 2020-01-02T10:24:21Z  2% S2MSI2A
bac67916-813e-4161-82a9-110f528511c3 ... 2020-01-17T10:22:49Z  7% S2MSI2A
df6de236-ede3-4d12-befb-2700df6c65e2 ... 2020-02-11T10:21:41Z 49% S2MSI2A
...

By default the module returns products for last 60 days. Let’s change search period by start and end options. To be sure that our AOI is fully covered by a Sentinel product we also set area_relation option. We can also limit products by clouds coverage percentage threshold.

i.sentinel.download -l map=jena_boundary producttype=S2MSI2A settings=sentinel.txt \
start=2019-04-01 end=2019-10-01 area_relation=Contains clouds=10
6 Sentinel product(s) found
a0ae6f58-4890-4382-bbd8-571874bfc65e ... 2019-06-26T10:20:31Z  1% S2MSI2A
caa11e7b-454d-4301-86b9-4c11659cc8a1 ... 2019-04-17T10:20:31Z  3% S2MSI2A
31ad53f4-146a-41a8-bce6-d9e99dfd7f66 ... 2019-04-22T10:20:29Z  3% S2MSI2A
...

Tip

If more products have been found you can limit search by limit option.

Let’s download desired product(s). Just remove -l flag and add output option in order to define path to output directory where data should be saved.

i.sentinel.download map=jena_boundary producttype=S2MSI2A settings=sentinel.txt \
start=2019-04-01 end=2019-10-01 area_relation=Contains clouds=10 \
limit=1 output=/home/user/geodata/sentinel/2019

Note

Pre-downloaded Sentinel scene is available in sample dataset:

geodata/sentinel/2019/S2A_MSIL2A_20190626T102031_N0212_R065_T32UPB_20190626T125319.SAFE.

Tip

Before importing or linking data try to print list of filtered raster files including projection match (second column 1 for match otherwise 0). If projection of input data differs from current location consider reprojection (-r) or creating a new location for import.

i.sentinel.import -p input=/home/user/geodata/sentinel/2019 pattern="20190626T102031_B0(4|8)_10m"
...L2A_T32UPB_A020940_20190626T102028/IMG_DATA/R10m/T32UPB_20190626T102031_B08_10m.jp2 1 (EPSG: 32632)
...L2A_T32UPB_A020940_20190626T102028/IMG_DATA/R10m/T32UPB_20190626T102031_B04_10m.jp2 1 (EPSG: 32632)

In the next step downloaded data can be imported to GRASS by i.sentinel.import. The command will import all Sentinel bands from input directory recursively. Sentinel bands to be imported can be optionally filtered by pattern option. In example below 4th and 8th bands in 10m resolution will be imported. By default input data are imported into GRASS format, alternatively data can be linked if -l is given. It is also useful to import cloud mask vector features by -c flag.

i.sentinel.import -l -c input=/home/user/geodata/sentinel/2019 pattern="20190626T102031_B0(4|8)_10m"

Now start our NDVI sample script created in Unit 12 - Script User Interface (ndvi-v3.py), enter input parameters and run.

../_images/run-script.png

Fig. 112 Run script to compute NDVI classes.

../_images/ndvi-classes.png

Fig. 113 Resultant NDVI classes for AOI.