sen2r is an R library which helps to download and preprocess Sentinel-2 optical images. The purpose of the functions contained in the library is to provide the instruments required to easily perform (and eventually automate) all the steps necessary to build a complete Sentinel-2 processing chain, without the need of any manual intervention nor the needing to manually integrate any external tool.
In particular, sen2r allows to:
Setting the execution of this processing chain is particularly easy using the sen2r GUI, which allows to set the parameters, to directly launch the main function or to save them in a JSON file which can be used to launch the processing at a later stage.
The possibility to launch the processing with a set of parameters saved in a JSON file (or directly passed as function arguments) makes easy to build scripts to automatically update an archive of Sentinel-2 products. Specific processing operations (i.e. applying Sen2Cor on Level-1c SAFE products, merging adjacent tiles, computing spectral indices from existing products) can also be performed using intermediate functions (see usage).
The package can be installed from GitHub with the R package remotes:
For detailed instructions about installing the package (including dependencies), see the Installation page.
The simplest way to use sen2r is to execute it in interactive mode:
this opens a GUI which allows to set the required processing parameters, and then launches the main function.
sen2r() can be launched with a list of parameters (created with
s2_gui()) or passing manually the parameters as arguments of the function (see the documentation of the function for further details).
Other specific functions can be used to run single steps separately:
s2_list()to retrieve the list of available Sentinel-2 products basing on input parameters;
s2_download()to download Sentinel-2 products;
sen2cor()to correct level-1C products using Sen2Cor;
s2_translate()to convert Sentinel-2 products from SAFE format to a format managed by GDAL;
s2_merge()to merge Sentinel-2 tiles which have the same date and orbit;
gdal_warp()to clip, reproject and warp raster files (this is a wrapper to call gdal_translate or gdalwarp basing on input parameters);
s2_mask()to apply a cloud mask to Sentinel-2 products;
s2_rgb()to generate RGB images from Sentinel-2 Surface Reflectance multiband raster files;
s2_calcindices()to compute maps of spectral indices from Sentinel-2 Surface Reflectance multiband raster files;
s2_thumbnails()to generate RGB thumbnails (JPEG or PNG) of the products.
The sen2r logo, partially derived from the R logo, is released under the Creative Commons Attribution-ShareAlike 4.0 International license (CC-BY-SA 4.0).
To cite this library, please use the following entry: