Finds the upstream and downstream lengths along a given flowpath (flowline in nhdplus terminology). Internally, the function rescales the reach measure to a flowpath measure and applies that rescaled measure to the length of the flowpath.
get_partial_length(hl, net = NULL, fl = NULL)
list containing a hydrologic location with names reachcode and reach_meas.
data.frame containing a flowpath network with reachcode, frommeas, tomeas, and lengthkm attributes. Not required if `fl` is provided.
data.frame containing one flowline that corresponds to the reachcode and measure of `hl`. Not required if `hl` is provided.
list containing `up` and `dn` elements with numeric length in km.
source(system.file("extdata", "walker_data.R", package = "nhdplusTools"))
hydro_location <- list(comid = 5329339,
reachcode = "18050005000078",
reach_meas = 30)
(pl <- get_partial_length(hydro_location, walker_flowline))
#> $dn
#> [1] 1.4358
#>
#> $up
#> [1] 3.3502
#>
hydro_location <- sf::st_sf(hydro_location,
geom = nhdplusTools::get_hydro_location(data.frame(hydro_location),
walker_flowline))
net <- navigate_network(hydro_location,
mode = "DM", network = walker_flowline,
distance_km = 4, trim_start = TRUE)
#> Loading required namespace: lwgeom
plot(sf::st_geometry(walker_flowline[walker_flowline$COMID == hydro_location$comid,]))
plot(sf::st_geometry(hydro_location), add = TRUE)
plot(sf::st_geometry(net), add = TRUE, col = "blue", lwd = 2)
sf::st_length(net)
#> 2384.619 [m]
pl$dn
#> [1] 1.4358