source(system.file("extdata", "sample_flines.R", package = "nhdplusTools"))
hydro_location <- sf::st_sf(id = c(1, 2, 3),
geom = sf::st_sfc(list(sf::st_point(c(-76.86934, 39.49328)),
sf::st_point(c(-76.91711, 39.40884)),
sf::st_point(c(-76.88081, 39.36354))),
crs = 4326),
totda = c(23.6, 7.3, 427.9),
nameid = c("Patapsco", "", "Falls Run River"))
flowpath <- dplyr::select(sample_flines,
comid = COMID,
totda = TotDASqKM,
nameid = GNIS_NAME,
REACHCODE,
ToMeas,
FromMeas)
indexes <- get_flowline_index(flowpath,
hydro_location,
search_radius = 0.2,
max_matches = 10)
disambiguate_flowline_indexes(indexes,
dplyr::select(flowpath, comid, totda),
dplyr::select(hydro_location, id, totda))
result <- disambiguate_flowline_indexes(indexes,
dplyr::select(flowpath, comid, nameid),
dplyr::select(hydro_location, id, nameid))
result[result$id == 1, ]
result[result$id == 2, ]
result[result$id == 3, ]
Run the code above in your browser using DataLab