-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path01-setup.Rmd
138 lines (90 loc) · 6.54 KB
/
01-setup.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Setup {.unnumbered}
## How to use this on-line book {.unnumbered}
This book contains reproducible code that can be run on an R environment. There are three options to setup your working environment:
1. Install R and RStudio and the packages required by `sits`, with specific procedures for each type of operating systems.
2. Use a Docker image provided by the Brazil Data Cube.
3. Install `sits` and all its dependencies using `conda`.
## How to install sits using R and RStudio {.unnumbered}
We suggest a staged installation, as follows:
1. Get and install base R from [CRAN](https://cran.r-project.org/).
2. Install RStudio from the [Posit website](https://posit.co/).
### Installing `sits` from CRAN {.unnumbered}
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. In what follows, we describe how to use CRAN to `sits` on Windows, Linux and MacOS.
### Installing in Microsoft Windows and MacOS environments{.unnumbered}
Windows and MacOS users are strongly encouraged to install binary packages from CRAN. The `sits` package relies on the `sf` and `terra` packages, which require the GDAL and PROJ libraries. Run RStudio and install binary packages `sf` and `terra`, in this order:
```{r, eval = FALSE}
install.packages("sf")
install.packages("terra")
```
After installing the binaries for `sf` and `terra`, install `sits` as follows;
```{r, eval = FALSE}
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 package `devtools` to install `sitsdata`.
```{r, eval = FALSE}
install.packages("devtools")
devtools::install_github("e-sensing/sitsdata")
```
To install `sits` from source, please install [Rtools](https://cran.r-project.org/bin/windows/Rtools/) for Windows to have access to the compiling environment. For Mac, please follow the instructions available [here](https://mac.r-project.org/tools/).
### Installing in Ubuntu environments{.unnumbered}
For Ubuntu, the first step should be to install 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:
``` sh
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`. After installing GDAL, GEOS, and PROJ4, please install packages `sf` and `terra`:
```{r, eval = FALSE}
install.packages("sf")
install.packages("terra")
```
Then please proceed to install `sits`, which can be installed as a regular **R** package.
```{r, eval = FALSE}
install.packages("sits", dependencies = TRUE)
```
### Installing in Debian environments{.unnumbered}
For Debian, use the [rocker geospatial](https://github.com/rocker-org/geospatial) dockerfiles.
### Installing in Fedora environments {.unnumbered}
In the case of Fedora, the following command installs all required dependencies:
```{sh, eval = FALSE}
sudo dnf install gdal-devel proj-devel geos-devel sqlite-devel udunits2-devel
```
## Using Docker images {.unnumbered}
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:
- [Version for R and RStudio](https://hub.docker.com/r/brazildatacube/sits-rstudio).
- [Version for Jupyter Notebooks](https://hub.docker.com/r/brazildatacube/sits-jupyter).
On a Windows or Mac platform, install [Docker](https://docs.docker.com/desktop/install/windows-install/) and then obtain one of the two images listed above from the Brazil Data Cube. Both images contain the full `sits` running environment. When GDAL is running in `docker` containers, please add the security flag `--security-opt seccomp=unconfined` on start.
## Install `sits` from CONDA {.unnumbered}
Conda is an open-source, cross-platform package manager. It is a convenient way to installl Python and R packages. To use `conda`, first download the software from the [CONDA website](https://conda.io/projects/conda/en/latest/index.html). After installation, use `conda` to install sits from the terminal as follows:
```{bash, eval = FALSE}
# add conda-forge to the download channels
conda config --add channels conda-forge
conda config --set channel_priority strict
# install sits using conda
conda install conda-forge::r-sits
```
The conda installer will download all packages and libraries required to run `sits`. This is the easiest way to install `sits` on Windows.
## Accessing the development version {.unnumbered}
The source code repository of `sits` is on [GitHub](https://github.com/e-sensing/sits). 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:
```{r, eval = FALSE}
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:
```{r, eval = FALSE}
install.packages("devtools")
devtools::install_github("e-sensing/sits@dev", dependencies = TRUE)
```
## Additional requirements {.unnumbered}
To run the examples in the book, please also install the `sitsdata` package. We recommend installing it using `wget`. See instructions in the [GNU Wget site](https://www.gnu.org/software/wget/).
```{r, eval = FALSE}
options(download.file.method = "wget")
devtools::install_github("e-sensing/sitsdata")
```
## Using GPUs with `sits` {.unnumbered}
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](https://torch.mlverse.org/docs/articles/installation.html).
```{r, eval = FALSE}
install.packages("torch")
```