Instruction are provided separately for each OS:

Alternatively, sen2r can be used in a Docker container.

On Linux systems

Installing dependencies

Before installing sen2r, it is recommended to check R (v. 3.4.4 or higher) and the following libraries to be present:

Other binaries are required (or suggested), since they are used in runtime by the package:

  • GDAL (with support for JP2OpenJPEG format): this is a mandatory dependency, needed for all the processing operations and to retrieve metadata from SAFE products;
  • Sen2Cor is used to perform atmospheric correction of Sentinel-2 Level-1C products: it is required by the package, unless you choose not to correct products locally (using only Level-1C – TOA products or downloading directly Level-2A products).
  • aria2 is an alternative downloader which can be used to faster the download of SAFE archives; it can be optionally installed and used.

To install both package dependencies and runtime binaries (excepting sen2cor, which is installed by sen2r):

Installing sen2r

Before proceeding, it is suggested to update the existing R packages:

update.packages(ask = FALSE)

Doing that, the following warning could appear:

Warning in install.packages(update[instlib == l, "Package"], l, contriburl = contriburl,  :
  'lib = "/usr/lib/R/library"' is not writable
Would you like to use a personal library instead?  (y/n)

If so, press y and continue. Moreover, if no personal libraries already exist, it is asked to create a new one: ask y and continue.

After that, the package can be installed from CRAN:

Alternatively, the development version can be installed from GitHub with the R package remotes. To do it:

  1. install the package remotes, if missing:

    install.packages("remotes")
  2. load it and install sen2r:

    library(remotes)
    install_github("ranghetti/sen2r")

This will install the R package along with its package dependencies, containing all the functions necessary to preprocess data.

Finally, sen2cor can be installed from R:

On Windows

Installing sen2r

R must be installed before proceeding.

In the case it was already installed, it is suggested to update the existing R packages:

update.packages(ask = FALSE)

sen2r can be installed from CRAN:

Alternatively, the development version can be installed from GitHub with the R package remotes. To do it:

  1. install the package remotes, if missing:

    install.packages("remotes")
  2. load it and install sen2r:

    library(remotes)
    install_github("ranghetti/sen2r")

This will install the R package along with its package dependencies, containing all the functions necessary to preprocess data.

Installing runtime dependencies

To run the functions correctly, some external dependences are required:

  • GDAL (with support for JP2OpenJPEG format): this is a mandatory dependency, needed for all the processing operations and to retrieve metadata from SAFE products. To avoid incompatibilities, starting from sen2r
    1. 1.1.0 it is strictly mandatory to use a GDAL installation provided with the OSGeo4W installer: if this requirement is not satisfied, it is possible to install GDAL with OSGeo4W directly from R (see below);
  • Sen2Cor is used to perform atmospheric correction of Sentinel-2 Level-1C products: it is required by the package, unless you choose not to correct products locally (using only Level-1C – TOA products or downloading directly Level-2A products).
  • aria2 is an alternative downloader which can be used to faster the download of SAFE archives; it can be optionally installed and used.

These dependences can be graphically checked launching the function

This function opens a GUI which help to check that they are satisfied; if some of them are missing, the GUI allows to install them directly.

On MacOS

Installing GDAL

In order to avoid incompatibilities with GDAL, starting from sen2r v. 1.1.0 it is strictly mandatory to use a GDAL installation provided with the OSGeo Homebrew repository. To do it:

  1. if Homebrew is missing on your system, install it opening a terminal and typing:

    (see the Homebrew webpage for details);
  2. install GDAL by typing:

    (see the OSGeo Homebrew webpage for details). At this step, an error could be returned in case another GDAL installation was already present; in this case, follow the instruction returned in the terminal to solve it (probably some packages must be unlinked with the instructions brew unlink <package>).

Installing sen2r

R must be installed before proceeding.

In the case it was already installed, it is suggested to update the existing R packages:

update.packages(ask = FALSE)

Packages can be installed using the compiled binaries, except from sp, sf, rgdal and rgeos, which are recommended to be compiled. To do it, use the command

install.packages(c("sp", "sf", "rgdal", "rgeos"), type = "source")

after having installed GDAL as described above.

sen2r can be installed from CRAN:

Alternatively, the development version can be installed from GitHub with the R package remotes. To do it:

  1. install the package remotes, if missing:

    install.packages("remotes")
  2. load it and install sen2r:

    library(remotes)
    install_github("ranghetti/sen2r")

This will install the R package along with its package dependencies, containing all the functions necessary to preprocess data.

Installing runtime dependencies

To run the functions correctly, some external dependences are required:

  • GDAL (with support for JP2OpenJPEG format): this is a mandatory dependency, needed for all the processing operations and to retrieve metadata from SAFE products. If the previous instructions were followed, it was already installed;
  • Sen2Cor is used to perform atmospheric correction of Sentinel-2 Level-1C products: it is required by the package, unless you choose not to correct products locally (using only Level-1C – TOA products or downloading directly Level-2A products).
  • aria2 is an alternative downloader which can be used to faster the download of SAFE archives; it can be optionally installed and used.

These dependences can be graphically checked launching the function

This function opens a GUI which help to check that they are satisfied; if some of them are missing, the GUI allows to install them directly.