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
)

Arguments

edges

An sf object with LINESTING geometry created using lines_to_lsn.

lsn_path

Local pathname to a directory in character format specifying where relationships.csv resides, which is created using link{lines_to_lsn}.

sum_col

Name of an existing column in edges (character format) that contains the value to sum downstream.

acc_col

Name of the new column in edges (character format) where the accumulated sum_col values will be stored (see details).

save_local

Logical indicating whether the updated edges should be saved to lsn_path in geopackage format. Defaults to TRUE.

overwrite

A logical indicating whether results should be overwritten if acc_col already exists in edges or edges.gpkg already exists in lsn_path and save_local = TRUE.

verbose

Logical. Indicates whether messages about the function progress should be printed to the console. Defaults to TRUE.

Value

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.

Details

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.