Learn R Programming

nhdplusTools (version 0.3.8)

calculate_arbolate_sum: Calculate Arbolate Sum

Description

Calculates arbolate sum given a dendritic network and incremental lengths. Arbolate sum is the total length of all upstream flowlines.

Usage

calculate_arbolate_sum(catchment_area)

Arguments

catchment_area

data.frame with ID, toID, and length columns.

Value

numeric with arbolate sum.

Examples

Run this code
# NOT RUN {
library(dplyr)
source(system.file("extdata", "walker_data.R", package = "nhdplusTools"))
catchment_length <- prepare_nhdplus(walker_flowline, 0, 0,
                             purge_non_dendritic = FALSE, warn = FALSE) %>%
  left_join(select(walker_flowline, COMID), by = "COMID") %>%
  select(ID = COMID, toID = toCOMID, length = LENGTHKM)

arb_sum <- calculate_arbolate_sum(catchment_length)

catchment_length$arb_sum <- arb_sum
catchment_length$nhd_arb_sum <- walker_flowline$ArbolateSu

mean(abs(catchment_length$arb_sum - catchment_length$nhd_arb_sum))
max(abs(catchment_length$arb_sum - catchment_length$nhd_arb_sum))

# }

Run the code above in your browser using DataLab