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)
#> Warning: Unknown or uninitialised column: `lengthkm`.
#> Error in pathlength_km[i] <- length_km[toids[i]] + pathlength_km[toids[i]]: replacement has length zero