Appendix 1: Software installation

While some software tools for conservation planning (e.g. Marxan or Zonation) 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 (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
  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 (sfand rnaturalearth) and a few more for data visualisation (patchwork and viridis). And of course we need prioritizr, which we will use for conservation planning.

::: {.cell}

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 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

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

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.

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 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.