In this repository is the code to prepare the data, run the prioritisation and produce the figures of the study "Protecting climate-resilient mangroves requires a small increase in the global protected area".
The code (in "Code") should be run sequentially, starting from the scripts in the "01_data_processing" folder, proceeding through the analysis in "02_prioritisation", and ending with plotting in "03_Figures".
Functions used in the scripts can be found in the "Functions" folder.
The code was written and tested in R version 4.4.0 on Microsoft Windows 11 Home, version 10.0.22631, build 22631.
Download and install R (https://cran.r-project.org/bin/windows/base/) and RStudio (https://posit.co/download/rstudio-desktop/)
Install the following packages in R to run the code and reproduce the results.
install.packages(c('tidyverse', 'sf', 'prioritizr', 'gurobi', 'terra', 'devtools', 'patchwork', 'sf', 'purrr', 'furrr', 'wdpar', 'parallel', 'tmap', 'openxlsx', 'ggeffects', 'ggstats', 'ggrepel', 'biscale', 'irr', 'ggnewscale', 'MetBrewer', 'spatstat', 'collapse', 'modelr', 'pacman'))
devtools::install_github("https://github.com/SpatialPlanning/spatialplanr")
devtools::install_github("emlab-ucsb/spatialgridr")
devtools::install_github("BlakeRMills/MoMAColors")
gurobi software is required to run the spatial prioritisation. It is possible to download it from: https://www.gurobi.com/downloads/.
It is possible to obtain a free academic licence at: https://www.gurobi.com/academia/academic-program-and-licenses/
Here is a guide on how to install gurobi: https://support.gurobi.com/hc/en-us/articles/4534161999889-How-do-I-install-Gurobi-Optimizer
This is a guide to install gurobi in R: https://support.gurobi.com/hc/en-us/articles/14462206790033-How-do-I-install-Gurobi-for-R
Typical installation time would take minutes to hours.
Cloning the content of the branch "demo", it is possible to run a demo of the content of the folder "Code/01_data_processing" using a smaller dataset to make it less computationally intensive. Running all the data processing code from the folder "Code/01_data_processing" from the branch "master" could take multiple days (or weeks, depending on the computing power of your machine).
Run time of the demo should be of approximately 1h.
The sensitivity analysis was run both producing larger planning units (1000 km²) and using 30% conservation targets instead of area-based targets. The code used to create larger planning units and intersect them with the layers of interest is currently located in the "devel_tin" branch. These results were obtained by running the code on the HPC Bunya. Still, it is possible to run the code in "02_prioritisation" and "03_Figures" without running the code in that branch, as the results are already included in the "Results" folder.
- Download or clone the GitHub repo in the branch 'master' and double-click the Mangroves_CC.Rproj file to open RStudio.
- The data to run the analysis, starting from the code in "Code/02_prioritisation", is provided as RDS.
- To run the analysis and generate the figures, start with the first script in "Code/02_prioritisation" and run the rest in sequential order, including those in "03_figures" and "04_patchwork_figures".
Typical run time is of a certain number of hours (up to a couple of days, depending on the computing power of your machine) without running the code in "Code/01_data_processing".
Data to run the code in "Code/01_data_processing" can be downloaded at:
- Global Mangrove Watch (https://www.globalmangrovewatch.org/)
- IUCN red list - mangrove species (https://www.iucnredlist.org/resources/spatial-data-download)
- Global biophysical typology of mangroves (https://zenodo.org/records/8340259)
- Probability of mangrove loss (https://github.com/cabuelow/mangrove-network-models?tab=readme-ov-file#probabilistic-forecasts-of-the-direction-of-future-change-in-mangrove-extent-using-network-models)