connectivity_matrix: Connectivity matrix

Description Usage Arguments Details Value Examples

Description

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.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## S4 method for signature 'Spatial,character'
connectivity_matrix(x, y,
  boundary_data = NULL, ...)

## S4 method for signature 'Spatial,Raster'
connectivity_matrix(x, y,
  boundary_data = NULL, ...)

## S4 method for signature 'Raster,Raster'
connectivity_matrix(x, y,
  boundary_data = NULL, included = NULL, ...)

Arguments

x

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

y

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 arugment 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 (ie. coordinate system, extent, resolution).

boundary_data

dsCMatrix-class object containing the shared boundary lengths between planning units. This argument defaults to NULL so that the boundary data will be automatically calculated.

included

integer vector indicating which cells in argument to x are planning units. This argument is only used when x is a Raster-class object. It defaults to NULL so that the cell indices are calculated automatically.

...

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.

Details

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, if argument to x is a Raster-class object then cells in x that contain missing (NA) values are omitted from the returned matrix. Furthermore, all cells along the diagonal are missing values since a planing unit does not have any share connectivity with itself.

Value

dsCMatrix-class sparse symmetric matrix object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## load data
# planning units
data(sim_pu_raster, sim_pu_polygons, sim_pu_lines, sim_pu_points)
# here we will use the features' habitat suitabilities as conductances
data(sim_features)

## create connectivity matrix using raster planning unit data
# extract 9 planning units
r <- crop(sim_pu_raster, c(0, 0.3, 0, 0.3))
# extact 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")
plot(cd, main = "conductivity")
plot(raster(as.matrix(cm_raster)), main = "connectivity")

## create connectivity matrix using polygon planning unit data
# subset 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")
plot(raster(as.matrix(cm_ply)), main = "connectivity")

prioritizr/prioritizrutils documentation built on May 25, 2019, 12:20 p.m.