From f1ce2c417893f925f91cf118bc2cafa7e6475dc7 Mon Sep 17 00:00:00 2001 From: David Blodgett Date: Thu, 10 Aug 2023 10:44:16 -0500 Subject: [PATCH] use st_intersects rather than st_intersection for subsetting in point indexing. fixes #11 --- NAMESPACE | 2 +- R/00_hydroloom.R | 2 +- R/index_points_to_lines.R | 7 +++--- tests/testthat/data/index_precision.gpkg | Bin 0 -> 110592 bytes tests/testthat/test_index.R | 29 +++++++++++++++++++++++ 5 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 tests/testthat/data/index_precision.gpkg diff --git a/NAMESPACE b/NAMESPACE index 3a07bc4..e40848a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -105,7 +105,7 @@ importFrom(sf,st_crs) importFrom(sf,st_drop_geometry) importFrom(sf,st_geometry) importFrom(sf,st_geometry_type) -importFrom(sf,st_intersection) +importFrom(sf,st_intersects) importFrom(sf,st_is_longlat) importFrom(sf,st_join) importFrom(sf,st_linestring) diff --git a/R/00_hydroloom.R b/R/00_hydroloom.R index fad6adb..3a8e495 100644 --- a/R/00_hydroloom.R +++ b/R/00_hydroloom.R @@ -196,7 +196,7 @@ get_outlet_value <- function(x) { #' @importFrom dplyr ungroup n rename row_number arrange desc distinct mutate summarise #' @importFrom dplyr everything as_tibble pull group_split tibble bind_cols lag case_when #' @importFrom rlang := -#' @importFrom sf "st_geometry<-" st_drop_geometry st_geometry st_geometry_type st_intersection +#' @importFrom sf "st_geometry<-" st_drop_geometry st_geometry st_geometry_type st_intersects #' @importFrom sf st_cast st_linestring st_is_longlat st_transform st_segmentize st_buffer #' @importFrom sf st_as_sf st_sf st_zm st_coordinates st_crs st_join st_reverse #' @importFrom pbapply pblapply pbsapply pbapply pboptions diff --git a/R/index_points_to_lines.R b/R/index_points_to_lines.R index 0ef5fa7..5af6e6e 100644 --- a/R/index_points_to_lines.R +++ b/R/index_points_to_lines.R @@ -212,8 +212,9 @@ index_points_to_lines.hy <- function(x, points, search_radius <- as.numeric(search_radius) # everything in same units now if(!is.na(precision)) { - suppressWarnings(x <- st_intersection(x, point_buffer)) - suppressWarnings(x <- st_cast(x, "LINESTRING", warn = FALSE)) + + x <- x[lengths(st_intersects(x, point_buffer, sparse = TRUE)) > 0, ] + } x <- select(x, any_of(c(id, aggregate_id, @@ -306,7 +307,7 @@ index_points_to_lines.hy <- function(x, points, x <- x |> add_index() |> filter(.data$L1 %in% matched$L1) |> - left_join(select(matched, all_of(c("L1", id))), by = "L1") |> + left_join(select(matched, all_of(c("L1", id))), by = "L1", relationship = "many-to-many") |> left_join(select(fline_atts, -"index"), by = id, relationship = "many-to-many") matched <- select(matched, point_id, node = "nn.idx", offset = "nn.dists", id) diff --git a/tests/testthat/data/index_precision.gpkg b/tests/testthat/data/index_precision.gpkg new file mode 100644 index 0000000000000000000000000000000000000000..77a872bec682c8a96f461cfb158939218c7b586a GIT binary patch literal 110592 zcmeHw30zcF`~M8vu+F$6qH;wM&_RZ601@p9BV2`H8&q7HMrMG~VFqUg0e56Dw-z(a zB~4Q+b8RTIRV%Hm)T~UcEV0FW&D37Yt@QWYd*@v4T+qz=yw(4I_`qe(InQ~X=X}p| zp0nR6D#$U~4Mds6TB)-W38Ho)u~>8uL5M`60Qd`qKlIZRK6s%3{1=Nvk;mw8R{n@A zUOfL}fM|d=)EiGD)gVipi$tYBj8Wo`_ zq_VP9g+!zEO?*P7rj6g|nOpJJLD$^E(b|wr5 zA;Tkw=BNl^DiOsn(VBIY21276ts&HT@K>CZBj;&KsWmFP<#TCnt>jjz6$WE@g&iD# zAT#5A*aq2l+O0BH8Ec_=)oN|VsRkl5ub3_nrxKf3*LGq?p1Mc_E=8>&swQde_DUkZ zkjfo>Z%=wp*C6R#;8iIAM&mp{KtjI4Mco$m%3a*V+uN z{5TyKa9eYrDfn=>n*<*;xy@?R8uhJfx6)|V*0!o0I<~HLtgf~#T8M2;>s}Y-_Db7d zRvChNW_UyK=-#QNhS~DAu3cM|&TiD1v{plz)>daDqFjX0Sph!5W0UTnL7LL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myKaIB(6Sl~S{5<3r>xRh4QBhT;=7^FlN_3(YQqU>+3ev_W{cinw$Q#xMR&6K zg;XwCSVD|YmB?8Vnjm@>Aqh@R71xK{LK&K + sf::st_transform(5070) + flines_aoi <- sf::st_buffer(points, dist = units::as_units(5000, "m")) |> + sf::st_bbox() |> + sf::st_as_sfc() + + # Define objects that we'd pass to get_flowline_index + search_rad <- units::as_units(500, "m") + max_match <- 3 + precision <- 10 + flines <- sf::read_sf(list.files(pattern = "index_precision.gpkg", + full.names = TRUE, recursive = TRUE)) + + check <-index_points_to_lines(x = flines, points = points, + search_radius = search_rad, + max_matches = max_match, + precision = precision) |> + dplyr::filter(point_id == 2) + + expect_equal(length(unique(check$comid)), 3) +}) + test_that("disambiguate", { source(system.file("extdata", "sample_flines.R", package = "nhdplusTools"))