Calculates level paths using the stream-leveling approach of NHD and NHDPlus. In addition to a levelpath identifier, a topological sort and levelpath outlet identifier is provided in output. If arbolate sum is provided in the weight column, this will match the behavior of NHDPlus. Any numeric value can be included in this column and the largest value will be followed when no nameID is available.
get_levelpaths(x, override_factor = NULL, status = FALSE, cores = NULL)
data.frame with ID, toID, nameID, and weight columns.
numeric factor to use to override nameID. If `weight` is `numeric_factor` times larger on a path, it will be followed regardless of the nameID indication.
boolean if status updates should be printed.
numeric number of cores to use in initial path ranking calculations.
data.frame with ID, outletID, topo_sort, and levelpath columns. See details for more info.
levelpath provides an identifier for the collection of flowlines that make up the single mainstem flowpath of a total upstream aggregate catchment.
outletID is the catchment ID (COMID in the case of NHDPlus) for the catchment at the outlet of the levelpath the catchment is part of.
topo_sort is similar to Hydroseq in NHDPlus in that large topo_sort values are upstream of small topo_sort values. Note that there are many valid topological sort orders of a directed graph.
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(
ID = test_flowline$COMID,
toID = test_flowline$toCOMID,
nameID = walker_flowline$GNIS_ID,
weight = walker_flowline$ArbolateSu,
stringsAsFactors = FALSE)
get_levelpaths(test_flowline)
#> Warning: get_levelpaths is deprecated in favor of add_levelpaths in the hydroloom package.
#> ID outletID topo_sort levelpath
#> 1 5329303 5329303 1 1
#> 2 5329295 5329295 2 2
#> 3 5329293 5329303 3 1
#> 4 5329291 5329291 4 4
#> 5 5329305 5329303 5 1
#> 6 5329299 5329299 6 6
#> 7 5329297 5329299 7 6
#> 8 5329317 5329303 8 1
#> 9 5329333 5329333 9 9
#> 10 5329315 5329303 10 1
#> 11 5329313 5329313 11 11
#> 12 5329307 5329307 12 12
#> 13 5329311 5329313 13 11
#> 14 5329309 5329309 14 14
#> 15 5329817 5329313 15 11
#> 16 5329319 5329319 16 16
#> 17 5329323 5329313 17 11
#> 18 5329335 5329335 18 18
#> 19 5329341 5329341 19 19
#> 20 5329345 5329335 20 18
#> 21 5329327 5329313 21 11
#> 22 5329325 5329313 22 11
#> 23 5329321 5329313 23 11
#> 24 5329841 5329313 24 11
#> 25 5329815 5329313 25 11
#> 26 5329347 5329347 26 26
#> 27 5329339 5329303 27 1
#> 28 5329337 5329337 28 28
#> 29 5329343 5329303 29 1
#> 30 5329371 5329371 30 30
#> 31 5329357 5329303 31 1
#> 32 5329375 5329375 32 32
#> 33 5329379 5329375 33 32
#> 34 5329405 5329405 34 34
#> 35 5329399 5329375 35 32
#> 36 5329377 5329377 36 36
#> 37 5329365 5329303 37 1
#> 38 5329363 5329363 38 38
#> 39 5329819 5329363 39 38
#> 40 5329355 5329355 40 40
#> 41 5329359 5329363 41 38
#> 42 5329373 5329303 42 1
#> 43 5329843 5329303 43 1
#> 44 5329845 5329845 44 44
#> 45 5329415 5329845 45 44
#> 46 5329847 5329303 46 1
#> 47 5329385 5329303 47 1
#> 48 5329427 5329427 48 48
#> 49 5329821 5329303 49 1
#> 50 5329413 5329413 50 50
#> 51 5329395 5329303 51 1
#> 52 5329419 5329419 52 52
#> 53 5329397 5329303 53 1
#> 54 5329387 5329387 54 54
#> 55 5329389 5329303 55 1
#> 56 5329391 5329391 56 56
#> 57 5329393 5329391 57 56
#> 58 5329849 5329391 58 56
#> 59 5329383 5329391 59 56
#> 60 5329871 5329391 60 56
#> 61 5329407 5329407 61 61
#> 62 5329435 5329303 62 1