Generates the main path length to a basin's terminal path.

get_pathlength(x)

Arguments

x

data.frame with ID, toID, length columns.

Value

data.frame containing levelpaths for each ID

Examples

source(system.file("extdata", "walker_data.R", package = "nhdplusTools"))

fl <- dplyr::select(prepare_nhdplus(walker_flowline, 0, 0),
                    ID = COMID, toID = toCOMID, length = LENGTHKM)
#> 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 0

get_pathlength(fl)
#>         ID pathlength
#> 1  5329303      0.000
#> 2  5329295      1.195
#> 3  5329293      1.195
#> 4  5329291      1.777
#> 5  5329305      1.777
#> 6  5329299      5.797
#> 7  5329297      7.206
#> 8  5329317      5.797
#> 9  5329333     10.240
#> 10 5329315     10.240
#> 11 5329313     12.924
#> 12 5329307     14.870
#> 13 5329311     14.870
#> 14 5329309     16.043
#> 15 5329817     16.043
#> 16 5329319     20.855
#> 17 5329323     20.855
#> 18 5329335     21.496
#> 19 5329341     22.878
#> 20 5329345     22.878
#> 21 5329327     21.496
#> 22 5329325     21.822
#> 23 5329321     22.473
#> 24 5329841     23.494
#> 25 5329815     27.094
#> 26 5329347     22.473
#> 27 5329339     12.924
#> 28 5329337     17.710
#> 29 5329343     17.710
#> 30 5329371     18.742
#> 31 5329357     18.742
#> 32 5329375     22.345
#> 33 5329379     24.666
#> 34 5329405     24.748
#> 35 5329399     24.748
#> 36 5329377     24.666
#> 37 5329365     22.345
#> 38 5329363     25.484
#> 39 5329819     26.764
#> 40 5329355     29.649
#> 41 5329359     29.649
#> 42 5329373     25.484
#> 43 5329843     26.943
#> 44 5329845     27.173
#> 45 5329415     27.521
#> 46 5329847     27.173
#> 47 5329385     28.463
#> 48 5329427     30.379
#> 49 5329821     30.379
#> 50 5329413     31.511
#> 51 5329395     31.511
#> 52 5329419     33.519
#> 53 5329397     33.519
#> 54 5329387     34.700
#> 55 5329389     34.700
#> 56 5329391     35.130
#> 57 5329393     35.306
#> 58 5329849     35.779
#> 59 5329383     36.172
#> 60 5329871     38.554
#> 61 5329407     35.306
#> 62 5329435     35.130