R/run_plus_attributes.R
add_plus_network_attributes.Rd
Given a river network with required base attributes, adds the NHDPlus network attributes: hydrosequence, levelpath, terminalpath, pathlength, down levelpath, down hydroseq, total drainage area, and terminalflag. The function implements two parallelization schemes for small and large basins respectively. If a number of cores is specified, parallel execution will be used.
add_plus_network_attributes(
net,
override = 5,
cores = NULL,
split_temp = NULL,
status = TRUE
)
data.frame containing comid, tocomid, nameID, lengthkm, and areasqkm. Additional attributes will be passed through unchanged. tocomid == 0 is the convention used for outlets. If a "weight" column is provided, it will be used in get_levelpaths otherwise, arbolate sum is calculated for the network and used as the weight.
numeric factor to be passed to get_levelpaths
integer number of processes to spawn if run in parallel.
character path to optional temporary copy of the network split into independent sub-networks. If it exists, it will be read from disk rather than recreated.
logical should progress be printed?
data.frame with added attributes
source(system.file("extdata", "walker_data.R", package = "nhdplusTools"))
test_flowline <- prepare_nhdplus(walker_flowline, 0, 0, FALSE)
#> Warning: removing geometry
#> Warning: Removed 0 flowlines that don't apply.
#> Includes: Coastlines, non-dendritic paths,
#> and networks with drainage area less than 0 sqkm, and drainage basins smaller than FALSE
test_flowline <- data.frame(
comid = test_flowline$COMID,
tocomid = test_flowline$toCOMID,
nameID = walker_flowline$GNIS_ID,
lengthkm = test_flowline$LENGTHKM,
areasqkm = walker_flowline$AreaSqKM)
add_plus_network_attributes(test_flowline)
#> # A tibble: 62 × 14
#> comid tocomid nameID lengthkm areasqkm weight terminalpa hydroseq levelpathi
#> <int> <dbl> <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 5.33e6 0 255208 1.20 0.868 137. 1 1 1
#> 2 5.33e6 5329303 255208 0.582 0.260 133. 1 3 1
#> 3 5.33e6 5329293 255208 4.02 3.76 127. 1 5 1
#> 4 5.33e6 5329305 255208 4.44 4.51 120. 1 8 1
#> 5 5.33e6 5329317 255208 2.68 3.64 112. 1 10 1
#> 6 5.33e6 5329315 255208 4.79 5.96 75.3 1 27 1
#> 7 5.33e6 5329339 255208 1.03 1.27 67.4 1 29 1
#> 8 5.33e6 5329343 255208 3.60 6.94 61.9 1 31 1
#> 9 5.33e6 5329357 255208 3.14 5.13 51.1 1 37 1
#> 10 5.33e6 5329365 254577 1.46 1.69 37.8 1 42 1
#> # ℹ 52 more rows
#> # ℹ 5 more variables: pathlength <dbl>, dnlevelpat <dbl>, dnhydroseq <dbl>,
#> # totdasqkm <dbl>, terminalfl <dbl>