"sen2r": An R Open Toolbox to Download and Preprocess Sentinel-2 Data and Time Series

Abstract

“sen2r” is an R package which allows to simplify and automate searching, download and preprocessing time series of Sentinel-2 optical data over user-selected areas of interest. The package is currently available on GitHub (https://github.com/ranghetti/sen2r), and is released under the GNU GPL-3 license. Its main purpose is to facilitate and speed up (and eventually automate) several steps which Sentinel-2 end users commonly perform by hand, including not only finding and downloading products matching certain spatial-temporal conditions, but also transforming them to an easier to use format and extracting / computing specific products (i.e. multiband Surface Reflectance images or Classification maps; spectral indices; RGB images). In particular, “sen2r” allows to: i) retrieve the list of available products on a selected area (which can be provided by specifying a bounding box, by loading a vector file or by drawing it on a map) in a given time window; ii) download the required SAFE products, being both Level-1C (Top-Of-Atmosphere reflectances) or Level-2A (Bottom-Of-Atmosphere reflectances); iii) automatically perform atmospheric correction using sen2cor (if Level-2A data is required and only Level-1C data is available); iv) clip the required output products (TOA/BOA reflectances, Surface Classification maps) on the specified area (adjacent tiles belonging to the same frame are merged), v) perform the required geometric manipulations (e.g. reprojection or rescaling); vi) mask cloudy pixels; vii) compute spectral indices; viii) create colour RGB images from surface reflectances (using any combination of spectral bands) and JPEG thumbnails for all the products. The package was developed in R, one of the most widespread programming languages among the scientific community. This allows data scientists to take advantage of powerful ready-to-use functions focused on Sentinel-2 data download and processing, giving them the instruments to easily build customised processing scripts. Nevertheless, usage of the package by people with limited R programming skills is considerably facilitated thanks to the “sen2r” Graphical User Interface (based on R Shiny). The GUI easily allows to define all processing parameters and to immediately launch the processing, or to store them in an external file for later use. The possibility to launch the processing with a set of saved parameters makes easy building scripts devoted to automatically update an archive of Sentinel-2 products over a specified area through scheduled execution of “sen2r”. The aforementioned characteristics make “sen2r” useful for different types of end users, from researchers (aiming at easily creating Sentinel-2 time series using a simple interface), to data scientists (which can use the “sen2r” R functions to build custom processing chains) and software engineers (which can schedule a processing chain to be used as the operational back-end of a service-oriented architecture). In the framework of the open data policy adopted for the Copernicus programme, “sen2r” open source package can therefore contribute to broaden the diffusion and usage of Sentinel-2 imagery.

Publication
2019 Living Planet Symposium, Milano, 13-17/05/2019