-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsoftware.qmd
More file actions
76 lines (49 loc) · 5.24 KB
/
software.qmd
File metadata and controls
76 lines (49 loc) · 5.24 KB
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
# Appendix 1: Software installation {#sec-appendix1}
While some software tools for conservation planning (e.g. [Marxan](https://marxansolutions.org/) or [Zonation](https://zonationteam.github.io/Zonation5/)) do not require coding skills beyond GIS skills for input data preparation, `prioritizr`, the tool that we will be using today, is written in `R` and therefore requires a basic understanding of the `R` programming language. This allows for fast and reproducible workflows by exploiting the advantages of the programming language. It also allows pre- and post-processing of your data, all in `R.`
Therefore, we need to install `R`, RStudio, and some other requirements for using `prioritizr`.
## Installation
Installing `R` on your machine is straightforward. Follow these steps:
1. Go to the [CRAN](http://cran.r-project.org) (Comprehensive `R` Archive Network) `R` website. If you type "r" into Google it is the first entry
2. Choose to download `R` for Linux, Mac or Windows
3. For Windows users, just install "base" and this will link you to the download file
4. For Mac users, choose the version relevant to your operating system, noting that if you have a new M1- or M2-powered Mac, you will need to download the Arm version
5. If you are a Linux user, you know what to do!
If you already have `R` installed, please make sure it has been updated recently.
## Installing *RStudio*
We will use *RStudio* in this workshop. *RStudio* is a free front-end to `R` for Windows, Mac or Linux (i.e., `R` is working in the background). It makes working with `R` easier, more productive and more organised, especially for new users. There are other front-ends, but *RStudio* is the most popular. To install:
1. Go to the [RStudio download website](https://posit.co/download/rstudio-desktop/)
2. Choose the *Download* button from the menu at the top, right-hand corner of the page
3. Choose the *Download* button beneath *RStudio Desktop*\
4. Download the correct version for your operating system
5. Install, and you're ready to go!
## Using *RStudio*: A quick guide!
*RStudio* has four main panes each in a quadrant of your screen. You can set what appears in each (through Tools/Options menu in Windows or *RStudio*/Preference on a Mac), but the default has:
- Console (bottom left)
- Source editor (top left)
- Environment and History (top right), and
- Plots, Files, Packages, Help, Viewer (bottom right).
## Installing required R packages
A really good R package to install the versions of the R packages that are in CRAN is **`pacman`**. We are going to install and load packages throughout the course of this workshop, but a common best practice is to install and load all necessary packages to run each script at the top of the R script.
To work through these notes you will need to install the add-on packages `tidyr`, `ggplot2` and `dplyr`. Or you can just get the package tidyverse which has these and more. We also need some packages for spatial data and spatial data wrangling (`sf`and `rnaturalearth`) and a few more for data visualisation (`patchwork` and `viridis`). And of course we need `prioritizr`, which we will use for conservation planning.
```{r, eval=FALSE}
install.packages("pacman")
pacman::p_load(tidyverse, sf, rnaturalearth, patchwork, prioritizr, viridis)
```
## Installing a solver
Solving conservation problems with `prioritizr` also requires having a solver installed on your machine. Solvers use specific algorithms that use mathematical optimization to find an optimal solution to a problem. There are many different solvers available that differ in terms of their efficiency and cost. The best solvers are usually expensive to use, but there are some good free ones available. For some more information on solver comparisons, see [this article](https://prioritizr.net/articles/solver_benchmarks.html) by Jeff Hanson, the developer of `prioritizr`.
For the purpose of this workshop, we recommend using one of the freely available solvers that are supported by `prioritizr` and are easily installed, such as the SYMPHONY solver, which can be installed using.
If you are a Windows user, lpsympony might work better. Check their website for more details: https://www.bioconductor.org/packages/release/bioc/html/lpsymphony.html
```{r eval=FALSE}
if (!require(remotes)) install.packages("remotes")
remotes::install_bioc("lpsymphony")
```
If you are a Mac/Linux, rcbc might work better. Check their README for more details https://github.com/dirkschumacher/rcbc
```{r eval=FALSE}
if (!require(remotes)) install.packages("remotes")
remotes::install_github("dirkschumacher/rcbc")
```
Alternatively, if the installation fails for some reason, on your machine, try installing the HiGHS solver.
```{r eval=FALSE}
install.packages("highs")
```
If you are affiliated with an academic institution, you might have access to a free academic license of Gurobi, one of the state-of-the-art solvers out there. While we will not go through a step-by-step guide on how to install Gurobi here, there are many resources on how to install Gurobi, for example [this installation guide](https://prioritizr.net/articles/gurobi_installation_guide.html) on the `prioritizr` website. We recommend using this solver if you have access to it and want to use conservation planning for projects after this workshop.