Learn R Programming

nhdplusTools (version 0.3.8)

calculate_total_drainage_area: Total Drainage Area

Description

Calculates total drainage area given a dendritic network and incremental areas.

Usage

calculate_total_drainage_area(catchment_area)

Arguments

catchment_area

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

Value

numeric with total area.

Examples

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

new_da <- calculate_total_drainage_area(catchment_area)

catchment_area$totda <- new_da
catchment_area$nhdptotda <- walker_flowline$TotDASqKM

mean(abs(catchment_area$totda - catchment_area$nhdptotda))
max(abs(catchment_area$totda - catchment_area$nhdptotda))

# }

Run the code above in your browser using DataLab