accum_edges {SSNbler} | R Documentation |
Accumulate (sum) edge values downstream in a Landscape Network (LSN)
accum_edges(
edges,
lsn_path,
sum_col,
acc_col,
save_local = TRUE,
overwrite = FALSE,
verbose = TRUE
)
edges |
An |
lsn_path |
Local pathname to a directory in character format
specifying where relationships.csv resides, which is created
using |
sum_col |
Name of an existing column in |
acc_col |
Name of the new column in |
save_local |
Logical indicating whether the updated
|
overwrite |
A logical indicating whether results should be
overwritten if |
verbose |
Logical. Indicates whether messages about the
function progress should be printed to the console. Defaults to
|
accum_edges
sums (i.e. accumulates) numeric
values in edges
downstream, from headwater or source
features to each network outlet feature (i.e. most downstream
line feature in each sub-network). Missing values are not allowed in
sum_col
and should be replaced with 0, or any other
meaningful numeric value, prior to running
accum_edges
. The acc_col
returned contains the
sum of sum_col
found in upstream edges, in addition the
the sum_col
for the edge itself. As such, acc_col
represents the cumulative upstream sum of sum_col
for the
downstream node of each line feature in edges
.
An sf
object representing edges in the LSN, with a
new acc_col
column. If save_local = TRUE
,
edges
is saved to lsn_path
in GeoPackage (.gpkg)
format.
# Get temporary directory, where the example LSN will be stored
# locally.
temp_dir <- tempdir()
# Build the LSN. When working with your own data, lsn_path will be
# a local folder of your choice rather than a temporary directory.
edges <- lines_to_lsn(
streams = MF_streams,
lsn_path = temp_dir,
snap_tolerance = 1,
check_topology = FALSE,
overwrite = TRUE,
verbose = FALSE
)
# Accumulate RCA area (rcaAreaKm2) downstream and store in a new
# column named WArea_km2
edges <- accum_edges(
edges = edges,
lsn_path = temp_dir,
sum_col = "rcaAreaKm2",
acc_col = "WArea_km2",
save_local = FALSE,
overwrite = TRUE,
verbose = FALSE
)
summary(edges$WArea_km2)