diff --git a/DESCRIPTION b/DESCRIPTION index b564dfcd..bffd05f4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -32,7 +32,7 @@ Imports: hydroloom, dataRetrieval, dplyr, sf, units, magrittr, jsonlite, httr, x Suggests: testthat, knitr, rmarkdown, ggmap, ggplot2, lwgeom, gifski, leaflet, httptest, future, future.apply License: CC0 Encoding: UTF-8 -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 VignetteBuilder: knitr Config/testthat/parallel: true Config/testthat/edition: 3 diff --git a/R/get_nhdplushr.R b/R/get_nhdplushr.R index 420de67a..97e84b68 100644 --- a/R/get_nhdplushr.R +++ b/R/get_nhdplushr.R @@ -86,7 +86,7 @@ get_nhdplushr <- function(hr_dir, out_gpkg = NULL, layer_set <- lapply(gdbs, get_hr_data, layer = layer, ...) - out <- do.call(rbind, layer_set) + out <- dplyr::bind_rows(layer_set) try(out <- st_sf(out)) } @@ -123,8 +123,11 @@ get_hr_data <- function(gdb, layer = NULL, min_size_sqkm = NULL, simp = NULL, proj = NULL, rename = TRUE) { if(layer == "NHDFlowline") { hr_data <- suppressWarnings(read_sf(gdb, "NHDPlusFlowlineVAA")) - hr_data <- select(hr_data, -ReachCode, -VPUID) - hr_data <- left_join(st_zm(read_sf(gdb, layer)), hr_data, by = "NHDPlusID") + hr_data <- select(hr_data, -dplyr::matches(c("ReachCode", "VPUID"), ignore.case = TRUE)) + + join_col <- names(hr_data)[grepl("nhdplusid", names(hr_data), ignore.case = TRUE)] + + hr_data <- left_join(st_zm(read_sf(gdb, layer)), hr_data, by = join_col) fix <- which( # In the case things come in as non-linestring geometries !sapply(st_geometry(hr_data), diff --git a/R/index_nhdplus.R b/R/index_nhdplus.R index 3cb242df..2a57ea3a 100644 --- a/R/index_nhdplus.R +++ b/R/index_nhdplus.R @@ -71,16 +71,18 @@ get_flowline_index <- function(flines, points, precision = NA, max_matches = 1) { - search_radius <- hydroloom:::check_search_radius(search_radius, points) - - point_buffer <- sf::st_buffer(points, search_radius) - if(is.character(flines) && flines == "download_nhdplusv2") { if((!is.null(nrow(points)) && nrow(points)) == 1 | length(points) == 1) { + + search_radius <- hydroloom:::check_search_radius(search_radius, points) + req <- sf::st_buffer(points, search_radius) + } else { + req <- points + } flines <- align_nhdplus_names(