Setup
How to use this on-line book
This book contains reproducible code that can be run on an R environment. There are three options to setup your working environment:
- Install R and RStudio (for standard users).
- Use a Docker image provided by the Brazil Data Cube.
- Install from source (for advanced users, usually contributors).
Install sits using R and RStudio
The standard installation of sits
is from the Comprehensive R Archive Network (CRAN), a network of servers (also known as mirrors) from around the world that store up-to-date versions of basic code and packages for R. We suggest a staged installation, as follows:
- Get and install base R from CRAN.
- Install RStudio from the Posit website.
- Run RStudio and install packages
sf
andterra
, in this order, using the command line:
install.packages("sf")
install.packages("terra")
- Install
sits
:
install.packages("sits", dependencies = TRUE)
- To run the examples in the book, please also install
sitsdata
package, which is available from GitHub. It is necessary to use packagedevtools
to installsitsdata
.
install.packages("devtools")
devtools::install_github("e-sensing/sitsdata")
Using Docker images
If you are familiar with Docker, there are images for sits
available with RStudio or Jupyter notebook. Such images are provided by the Brazil Data Cube team:
On a Windows or Mac platform, install Docker and then obtain one of the two images listed above from the Brazil Data Cube. Both images contain the full sits
running environment.
Installation from source
The sits
package relies on the sf
and terra
packages, which require the GDAL and PROJ libraries. Please follow the instructions below for installing sf
and terra
together with GDAL, provided by Edzer Pebesma.
Windows and MacOS users are strongly encouraged to install the sf
and terra
binary packages from CRAN. To install sits
from source, please install Rtools for Windows to have access to the compiling environment. For Mac, please follow the instructions available here.
For Ubuntu, we recommend using the latest version of the GDAL, GEOS, and PROJ4 libraries and binaries. To do so, use the repository ubuntugis-unstable
, which should be done as follows:
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install libudunits2-dev libgdal-dev libgeos-dev libproj-dev
sudo apt-get install gdal-bin
sudo apt-get install proj-bin
Getting an error while adding this PPA repository could be due to the absence of the package software-properties-common
. When GDAL is running in docker
containers, please add the security flag --security-opt seccomp=unconfined
on start.
For Debian, use the rocker geospatial dockerfiles.
In the case of Fedora, the following command installs all required dependencies:
After installing GDAL, GEOS, and PROJ4, please install packages sf
and terra
, in this order.
install.packages("sf")
install.packages("terra")
After configuring GDAL, GEOS, and PROJ4, please proceed to install sits
, which can be installed as a regular R package.
install.packages("sits", dependencies = TRUE)
The source code repository of sits
is on GitHub. There are two versions available on GitHub: master
and dev
. The master
contains the current stable version, which is either the same code available in CRAN or a minor update with bug fixes. To install the master
version, install devtools
(if not already available) and do as follows:
install.packages("devtools")
devtools::install_github("e-sensing/sits", dependencies = TRUE)
To install the dev
(development) version, which contains the latest updates but might be unstable, install devtools
(if not already available), and then install sits
as follows:
install.packages("devtools")
devtools::install_github("e-sensing/sits@dev", dependencies = TRUE)
To run the examples in the book, please also install sitsdata
package.
options(download.file.method = "wget")
devtools::install_github("e-sensing/sitsdata")
Using GPUs with sits
The torch
package automatically recognizes if a GPU is available on the machine and uses it for training and classification. There is a significant performance gain when GPUs are used instead of CPUs for deep learning models. There is no need for specific adjustments to torch
scripts. To use GPUs, torch
requires version 11.6 of the CUDA library, which is available for Ubuntu 18.04 and 20.04. Please follow the detailed instructions for setting up torch
available here.
install.packages("torch")