1 Overview

The following section provides an example of possible workflow. 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. It is the user’s responsibility to ensure that all analysis decisions are valid.

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"

1.1 Landscape Data using Conservation Features

Download the example project folder. This folder contains the Marxan Connect Project file, the input data, and the output data from this example. Feel free to follow along using Marxan Connect by loading tutorial.MarCon.

Before adding connectivity to the mix, let’s have a look at the ‘traditional’ Marxan files which contain only representation targets. The files include reef planning units that cover the Great Barrier Reef and we’ve identified a few bioregion types for which we’ve set conservation targets.

1.1.1 spec.dat

spec <- read.csv("tutorial/CF_landscape/input/spec.dat")
datatable(spec,rownames = FALSE, options = list(searching = FALSE))

1.1.2 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_landscape/input/puvspr2.dat")
datatable(puvspr[1:30,],rownames = FALSE, options = list(searching = FALSE))

1.1.3 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_landscape/input/pu.dat")
datatable(pu[1:30,],rownames = FALSE, options = list(searching = FALSE))

1.1.4 Inital Conservation Feature

This map shows the bioregions and depth classes, 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_landscape/output/pu_no_connect.csv") %>%
    mutate(geometry=st_as_sfc(geometry,"+proj=longlat +datum=WGS84"),
           best_solution = as.logical(best_solution)) %>%
    st_as_sf() %>%
    left_join(puvspr_wide,by=c("pu_id"="pu"))
map <- leaflet(output) %>%
    addTiles()

groups <- names(select(output,-best_solution,-select_freq, -id, -pu_id, -Y_COORD, -X_COORD, -TARGET_FID, -GAZ_LOC_CO, -GBR_NAME, -Join_Count, -PERIMETER, -QLD_NAME, -REEFS_, -REEFS_ID, -REEF_ID, -SUB_ID, -status, -google_land_pu_R))[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")