View source: R/cs-all-to-one.R
| cs_all_to_one | R Documentation |
For each focal node in turn, inject current at all other focal nodes and ground that single node.
cs_all_to_one(
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 |
All-to-one mode iterates over each focal node. In each iteration, all other focal nodes are injected with 1 amp of current each, and the focal node is connected to ground. This produces a current map showing how current converges on that node from across the landscape.
This mode is useful for identifying the most accessible or reachable sites in the network, emphasizing current flow toward each ground node. The cumulative map sums across all iterations and highlights cells that are important for connectivity across the full set of nodes.
A terra::SpatRaster with the following layers:
Current flow summed across all iterations.
Per-node current map for focal node N, where
N is the integer node ID from the locations raster. One layer
per focal node.
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_pairwise(), cs_one_to_all(), 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_all_to_one(res, coords)
plot(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.