Create a matrix showing the connectivity between planning units. Connectivity is calculated as the average conductance of two planning units multiplied by the amount of shared boundary between the two planning units. Thus planning units that each have higher a conductance and share a greater boundary are associated with greater connectivity.

# S4 method for Spatial,character
connectivity_matrix(x, y, ...)

# S4 method for Spatial,Raster
connectivity_matrix(x, y, ...)

# S4 method for Raster,Raster
connectivity_matrix(x, y, ...)



Raster-class or Spatial-class object representing planning units. If x is a Raster-class object then it must contain a single band.


Raster-class object showing the conductance of different areas across the study area, or a character object denoting a column name in the attribute table of x that contains the conductance values. Note that argument to y can only be a character object if the argument to x is a Spatial-class object. Additionally, note that if argument to x is a Raster-class object then argument to y must have the same spatial properties as it (i.e. coordinate system, extent, resolution).


arguments passed to fast_extract for extracting and calculating the conductance for each unit. These arguments are only used if argument to x is a link[sp]{Spatial-class} object and argument to y is a Raster-class object.


dsCMatrix-class sparse symmetric matrix object.


This function returns a dsCMatrix-class sparse symmetric matrix. Each row and column represents a planning unit. Cell values represent the connectivity between two planning units. To reduce computational burden for Raster-class data, data are missing for cells with NA values in the argument to x. Furthermore, all cells along the diagonal are missing values since a planing unit does not share connectivity with itself.


# load data data(sim_pu_raster, sim_pu_polygons, sim_pu_lines, sim_pu_points, sim_features) # create connectivity matrix using raster planning unit data using # the raster cost values to represent conductance ## extract 9 planning units r <- crop(sim_pu_raster, c(0, 0.3, 0, 0.3)) ## extract conductance data for the 9 planning units cd <- crop(r, sim_features[[1]]) ## make connectivity matrix cm_raster <- connectivity_matrix(r, cd) ## plot data and matrix
par(mfrow = c(1,3)) plot(r, main = "planning units", axes = FALSE, box = FALSE) plot(cd, main = "conductivity", axes = FALSE, box = FALSE) plot(raster(as.matrix(cm_raster)), main = "connectivity", axes = FALSE, box = FALSE)
# create connectivity matrix using polygon planning unit data using # the habitat suitability data for sim_features[[1]] to represent # planning unit conductances ## subset data to 9 polygons ply <- sim_pu_polygons[c(1:2, 10:12, 20:22), ] ## make connectivity matrix cm_ply <- connectivity_matrix(ply, sim_features[[1]]) ## plot data and matrix
par(mfrow = c(1,3)) plot(ply, main = "planning units") plot(sim_features[[1]], main = "conductivity", axes = FALSE, box = FALSE) plot(raster(as.matrix(cm_ply)), main = "connectivity", axes = FALSE, box = FALSE)