Unit 18 - 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).

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

Fig. 104 Install i.sentinel GRASS Addon.

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

Note

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

pip install sentinelsat

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

First we are going to create a new mapset (Settings ‣ GRASS working environment ‣ Create new mapset) in oslo-region location from Unit 02 - First steps to store all the Sentinel data and start to work in it.

../_images/sentinel_mapset.png

Fig. 105 Create a new mapset for Sentinel data and switch to it.

Note

It is possible to create a new mapset and switch to it using g.mapset GRASS module.

g.mapset -c mapset=sentinel

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 Oslo county imported in Unit 03 - Data Management.

Now we can search for suitable Sentinel products. 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 with your 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=oslo producttype=S2MSI2Ap settings=sentinel.txt
No product found

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=oslo producttype=S2MSI2Ap settings=sentinel.txt \
start=2017-04-01 end=2017-10-01 area_relation=Contains clouds=10
3 Sentinel product(s) found
2a894e37-1cf5-4bfc-ab42-9e32b99f423f 2017-05-23T10:40:31Z  1% S2MSI2Ap
71e0c5be-d008-4b71-a8f3-97f4c42ba09a 2017-05-06T10:50:31Z  2% S2MSI2Ap
74cf18cf-3cae-4d80-b1c8-9f2ee29972b4 2017-05-26T10:50:31Z  4% S2MSI2Ap

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=oslo producttype=S2MSI2Ap settings=sentinel.txt \
start=2017-01-01 end=2017-10-01 area_relation=Contains clouds=10 limit=1 output=geodata/sentinel/2017

Note

Pre-downloaded Sentinel scene is available in sample dataset:

geodata/sentinel/2017/S2A_MSIL2A_20170523T104031_N0205_R008_T32VNM_20170523T104025.SAFE.

Tip

Before importing or linking 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=geodata/sentinel/2017 pattern="20170523T104031_B0(2|3|4|8)_10m"

or

i.sentinel.import -p \
input=geodata/sentinel/2017/S2A_MSIL2A_20170523T104031_N0205_R008_T32VNM_20170523T104025.SAFE \
pattern="B0(2|3|4|8)_10m"
.../L2A_T32VNM_20170523T104031_B02_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 2nd, 3rd, 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=geodata/sentinel/2017 pattern="20170523T104031_B0(2|3|4|8)_10m"

RGB composition

Imported Sentinel bands can be vizualized as a RGB composition. Select grass-layer-rgb-add Add RGB map layer from the Layer Manager.

../_images/add_rgb.png

Fig. 106 Add RGB map layer.

The result appears really dark, see Fig. 107.

../_images/rgb_dark.png

Fig. 107 RGB composition with default grey color table.

Color table can be auto-balanced for RGB bands by GRASS module i.color.enhance. This module modifies the color table of each image band to provide a more natural color mixture, the base data remains untouched.

../_images/icolorsenhance.png

Fig. 108 Auto-balance color table for RGB composition.

To see enhanced RGB composition click on grass-layer-redraw Render map in Map Display.

../_images/rgb_good.png

Fig. 109 Enhanced RGB composition.