Introducing connectivity models
By Matt Williamson
April 12, 2022
Graphs and wildlife connectivity
Connectivity describes the degree to which the landscape allows for the movement of genes, individuals, or species to traverse the landscape in order to access resources, find mates, or avoid mortality. As habitats have become increasingly fragmented, conservation practitioners are increasingly focused on developing strategies for maintaining or restoring connectivity between existing habitats or protected areas. Although high resolution telemetry data coupled with various step-selection functions can tell us something about how individuals use the landscape during their daily or seasonal movements, the ability to scale those individual movements to the population- or species-levels or longer temporal scales often requires different approaches. As we discussed, graph theory (or the closely related network or circuit theory) is frequently used as a means of assessing landscape connectivity. The bulk of graph/network analyses in R
rely on the igraph
package (or wrappers that point to functions from igraph
like tidygraph
). Getting started with spatial graphs is challenging because:
The number of metrics describing graphs can be overwheliming
There are always multiple ways to do things in
R
With those caveats in mind, I hope that by the end of working through this example you will be able to:
Use georeferenced data to construct simple graphs where edges are based on distance
Estimate and/or visualize a variety of the metrics described in Rayfield et al. 2016
Implement edge thinning and node removal to understand how loss of patches or edges alter the network structure (sensu Urban and Keitt 2001)
if(!"remotes" %in% installed.packages()) {
install.packages("remotes")
}#this code checks if remotes is installed and installs it if not
= c(
cran_pkgs "sf",
"tidygraph",
"igraph",
"here",
"tmap",
"units",
"ggraph",
"netrankr",
"raster",
"gdistance",
"tidyr",
"FedData")
::install_cran(cran_pkgs)
remotes#remotes install_cran only installs if the packages don't exist or if they need updating
Load your libraries and then some data
We’ll need a few different libraries to be able to bring in spatial data and then convert it into a graph form, so we’ll load those here. Remember that, ?
, followed by the package name can help you access the different helpfiles for each function in the package. Since you all work on things that fly, I thought we’d start by using a dataset on birds. We’ll use the 2015 Priority Areas for Conservation (PACs) for the Greater Sage Grouse. PACs represent areas identified as essential for the long-term conservation of the sage-grouse (you can learn more about this dataset here. As such, we might imagine that connectivity among these PACs is also important making them a reasonable choice for our analysis.
library(sf)
library(igraph)
library(tidygraph)
library(tmap)
library(units)
library(ggraph)
#library(tidyr)
#library(FedData)
<- st_read("data/GRSG_2015_USFWS_StatusReview_PACs.shp") %>%
sg.pacs st_make_valid()
## Reading layer `GRSG_2015_USFWS_StatusReview_PACs' from data source
## `/Users/matthewwilliamson/Websites/spaseslab.com/content/blog/intro-graphs/data/GRSG_2015_USFWS_StatusReview_PACs.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 301 features and 9 fields
## Geometry type: POLYGON
## Dimension: XY
## Bounding box: xmin: -1361708 ymin: 381165.6 xmax: 147308.4 ymax: 1661769
## Projected CRS: GRSG Range Wide
::tmap_mode("view")
tmap::qtm(sg.pacs, basemaps = leaflet::providers$Stamen.TerrainBackground) tmap