Installing Sen2r on Linux Systems
This instruction shows how to install Sen2r which is an R library that helps to download and preprocess Sentinel-2 optical images.
Before installing sen2r, it is recommended to check R (v. 3.4.4 or higher) and the following libraries to be installed:
- GDAL, PROJ and GEOS (required by rgdal and rgeos);
- jq (required by jqr);
- protobuf (required by protolite);
- V8 (required by geojsonio);
- openssl (required by openssl);
- cairo (required by gdtools);
- libcurl (required by curl);
- NetCDF (required by ncdf4);
- libxml2 (required by XML).
Some external dependencies are required to run specific sen2r features:
- 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);
- GDAL is required to smooth/bufferise a cloud mask, and can be optionally used to compute spectral indices, RGB images and thumbnails;
- aria2 is an alternative downloader which can be used to faster the download of SAFE archives; it can be optionally installed and used.
These commands should be run in the Terminal.
On Ubuntu 22.04:
sudo apt install -y r-base gdal-bin aria2 libpython2-dev libudunits2-dev libgdal-dev libjq-dev libprotobuf-dev protobuf-compiler libv8-dev libssl-dev libcairo2-dev
Older distros:
sudo apt-get install -y r-base gdal-bin python-gdal aria2 libpython-dev libudunits2-dev libgdal-dev libjq-dev libprotobuf-dev protobuf-compiler libv8-dev libssl-dev libcairo2-dev
On Ubuntu 16.04 LTS Xenial:
sudo add-apt-repository -y ppa:opencpu/jq sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable sudo apt-get update -q
On Debian:
sudo apt-get install -y r-base gdal-bin python-gdal aria2 libpython-dev libudunits2-dev libgdal-dev libjq-dev libprotobuf-dev protobuf-compiler libnode-dev libssl-dev libcairo2-dev proj-epsg
On Fedora:
sudo yum install R gdal gdal-python aria2 python-devels gdal-devel proj-devel geos-devel udunits2-devel jq-devel protobuf-devel v8-devel openssl-devel cairo-devel libcurl-devel netcdf-devel libxml2-devel
On ArchLinux:
sudo pacman -S — noconfirm r base-devel gcc-fortran python-gdal wget aria2 jq protobuf git cd /tmp; git clone https://aur.archlinux.org/gyp-git.git cd gyp-git; makepkg -si — noconfirm cd /tmp; git clone https://aur.archlinux.org/v8-3.14.git cd v8–3.14; makepkg -si — noconfirm cd /tmp; git clone https://aur.archlinux.org/udunits.git cd udunits; makepkg -si — noconfirm
Installation was tested on the date 2022–07–13.
These commands should be run in R. Please run R and run the commands in R.
Installing sen2r
Update the existing R packages:
update.packages(ask = FALSE)
Installing sen2r
install.packages(“sen2r”)
Alternatively
install.packages(“remotes”)
library(remotes)
install_github(“ranghetti/sen2r”)
Usage
library(sen2r)
sen2r()
Errors:
If you are facing errors as figure below, Please do again from the beginning of this article. Some errors can be protolite, units, jqr, geojson, sf, lwgeom, geojsonio, stars, etc.
Finished.
If you have any feedback or encounter problems using these instructions please leave a comment.
Please follow me, I will follow back you. Thanks.