View source: R/cs-one-to-all.R
| cs_one_to_all | R Documentation |
For each focal node in turn, inject current at that node and ground all other focal nodes simultaneously.
cs_one_to_all(
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 |
One-to-all mode iterates over each focal node. In each iteration, the focal node is injected with 1 amp of current and all remaining focal nodes are simultaneously connected to ground. This produces a current map showing how current spreads from that node through the landscape to reach the others.
This mode is useful for mapping how well each site is connected to the rest of the focal node network, emphasizing current dispersal from each source. 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_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_one_to_all(res, coords)
plot(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.