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