The following section provides an example of a possible workflow using demographic connectivity data as a conservation feature in Marxan. It is important to note that these are indeed examples of the software’s capabilities and are not intended to be used as scientific advice in a spatial conservation planning process.
The maps and plots shown in this tutorial were created in R using the shapefile exported from the “Plotting Options” tab of Marxan Connect. The R code used to make the plots can be revealed by clicking on the Code
button below
library(sf)
library(leaflet)
library(tmap)
library(tidyverse)
library(DT)
# set default projection for leaflet
proj <- "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"
In this case study, we will be working with data from the Great Barrier Reef in Australia. Our represenation features consist of a subset of bioregions identified by the Great Barrier Reef Marine Park Authority and the connectivity input data consists of calculated probabilities from the spatial distribution of reefs and estimated biological parameters.
Download the example project folder. This folder contains the Marxan Connect Project file, input data, and output data for this example.
Before opening Marxan Connect, let’s manually look through the Marxan database to view the standard set of input files (spec.dat, puvspr.dat, bound.dat, and pu.dat) in the input folder of the CF_demographic folder.
The planning unit file (hex_planning_units.shp) includes 653 hexagonal planning units that cover the Great Barrier Reef.
spec.dat
spec <- read.csv("tutorial/CF_demographic/input/spec.dat")
datatable(spec,rownames = FALSE, options = list(searching = FALSE))
puvspr.dat
The table shown here is a trimmed version showing the first 30 rows as an example of the type of data in the puvspr.dat file. The original dataset has 974 entries.
puvspr <- read.csv("tutorial/CF_demographic/input/puvspr.dat")
datatable(puvspr[1:30,],rownames = FALSE, options = list(searching = FALSE))
bound.dat
The table shown here is a trimmed version showing the first 30 rows as an example of the type of data in the bound.dat file. The original dataset has 3600 entries.
bound <- read.csv("tutorial/CF_demographic/input/bound.dat")
datatable(bound[1:30,],rownames = FALSE, options = list(searching = FALSE))
pu.dat
The table shown here is a trimmed version showing the first 30 rows as an example of the type of data in the pu.dat file. The original dataset has 653 entries.
pu <- read.csv("tutorial/CF_demographic/input/pu.dat")
datatable(pu[1:30,],rownames = FALSE, options = list(searching = FALSE))
This map shows the bioregions, which serve as conservation features in the Marxan analysis with no connectivity.
puvspr_wide <- puvspr %>%
left_join(select(spec,"id","name"),
by=c("species"="id")) %>%
select(-species) %>%
spread(key="name",value="amount")
# planning units with output
output <- read.csv("tutorial/CF_demographic/output/pu_no_connect.csv") %>%
mutate(geometry=st_as_sfc(geometry,"+proj=longlat +datum=WGS84"),
best_solution = as.logical(best_solution)) %>%
st_as_sf()
map <- leaflet(output) %>%
addTiles()
groups <- names(select(output,-best_solution,-select_freq,-google_demo_pu_discrete_median_to_maximum,-google_demo_pu,-status))[c(-1,-2)]
groups <- groups[groups!="geometry"]
for(i in groups){
z <- unlist(data.frame(output)[i])
if(is.numeric(z)){
pal <- colorBin("YlOrRd", domain = z)
}else{
pal <- colorFactor("YlOrRd", domain = z)
}
map = map %>%
addPolygons(fillColor = ~pal(z),
fillOpacity = 0.6,
weight=0.5,
color="white",
group=i,
label = as.character(z)) %>%
addLegend(pal = pal,
values = z,
title = i,
group = i,
position="bottomleft")
}
map <- map %>%
addLayersControl(overlayGroups = groups,
options = layersControlOptions(collapsed = FALSE))
for(i in groups){
map <- map %>% hideGroup(i)
}
map %>%
showGroup("BIORE_102")
The connectivity data is at the ‘heart’ of Marxan Connect’s functionality. It allows the generation of new conservation features and/or spatial dependencies to be characterized and included based on connectivity metrics. Let’s examine the spatial layers we’ve added in order to incorporate connectivity into this Marxan analysis. Marxan Connect needs a shapefile for the planning units, and optionally focus areas and avoidance areas. For simplicity, we have not included focus or avoidance areas in this tutorial. These spatial layers are shown in the map below.
# planning units
pu <- st_read("tutorial/CF_demographic/hex_planning_units.shp") %>%
st_transform(proj)
p <- qtm(pu,fill = '#7570b3')
tmap_leaflet(p) %>%
addLegend(position = "topright",
labels = c("Planning Units"),
colors = c("#7570b3"),
title = "Layers")