| cs_pairwise | R Documentation |
Compute pairwise effective resistances and cumulative current flow between all pairs of focal nodes.
cs_pairwise(
resistance,
locations,
resistance_is = "resistances",
four_neighbors = FALSE,
avg_resistances = FALSE,
short_circuit = NULL,
included_pairs = NULL,
write_voltage = FALSE,
cumulative_only = TRUE,
source_strengths = NULL,
solver = "cg+amg",
output_dir = NULL,
verbose = FALSE
)
resistance |
A terra::SpatRaster or file path. The resistance (or
conductance) surface. Higher values represent greater resistance to
movement. Use the |
locations |
Focal node locations, provided as any of:
|
resistance_is |
Character. Whether the resistance surface represents
|
four_neighbors |
Logical. Use 4-neighbor (rook) connectivity instead of
8-neighbor (queen). Default |
avg_resistances |
Logical. When using 8-neighbor connectivity, compute
the resistance of diagonal connections as the average of the two cells
rather than their sum. Default |
short_circuit |
Optional terra::SpatRaster or file path. Raster
identifying short-circuit regions (aka polygons). Cells sharing the same
positive integer value are treated as short-circuit regions with zero
resistance between them. Default |
included_pairs |
Optional character file path. A text file specifying
which pairs of focal nodes to include or exclude from analysis. See the
Circuitscape documentation for the file format. Default |
write_voltage |
Logical. Write voltage maps. Default |
cumulative_only |
Logical. If |
source_strengths |
Optional. Variable current injection strengths for each focal node. Can be:
|
solver |
Character. Solver to use: |
output_dir |
Optional character path. If provided, output files persist
there. Default |
verbose |
Logical. Print Circuitscape solver output. Default |
Pairwise mode iterates over every unique pair of focal nodes. For each pair, one node is injected with 1 amp of current and the other is connected to ground. The effective resistance between the pair is recorded, and the resulting current flow is accumulated across all pairs into a cumulative current map that highlights important movement corridors.
This is the most common Circuitscape mode and is typically used to quantify connectivity between discrete habitat patches or populations. The resistance matrix can be used as a distance metric in analyses such as isolation by resistance.
A named list with:
A terra::SpatRaster. By default contains a single
cumulative_current layer (current flow summed across all pairs). When
cumulative_only = FALSE, additional per-pair layers are included
(e.g., current_1_2, current_1_3). When write_voltage = TRUE,
per-pair voltage layers are included (e.g., voltage_1_2,
voltage_1_3).
A symmetric numeric matrix of pairwise effective resistances between focal nodes, with node IDs as row and column names.
McRae, B.H. (2006). Isolation by resistance. Evolution, 60(8), 1551–1561. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/j.0014-3820.2006.tb00500.x")}
Circuitscape.jl: https://docs.circuitscape.org/Circuitscape.jl/latest/
cs_one_to_all(), cs_all_to_one(), cs_advanced(), cs_setup()
library(terra)
res <- rast(system.file("extdata/resistance.tif", package = "circuitscaper"))
coords <- matrix(c(10, 40, 40, 40, 10, 10, 40, 10), ncol = 2, byrow = TRUE)
result <- cs_pairwise(res, coords, cumulative_only = FALSE)
plot(result$current_map)
result$resistance_matrix
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.