From 1b4b51145543255896591cab2d84bb938ac43c79 Mon Sep 17 00:00:00 2001 From: Nicolas Casajus Date: Wed, 21 Feb 2024 16:52:41 +0100 Subject: [PATCH] fix: subset polygons in iho by ocean names --- R/filter_by_ocean.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/R/filter_by_ocean.R b/R/filter_by_ocean.R index b6c2448..4b6e5fd 100644 --- a/R/filter_by_ocean.R +++ b/R/filter_by_ocean.R @@ -31,6 +31,11 @@ filter_by_ocean <- function(data, ocean) { stop("Some ocean names are mispelled. Please use 'get_ocean_names()' ", "to find the correct spelling", call. = FALSE) } + + + ## Select ocean polygons in IHO layer ---- + + iho <- iho_boundaries[which(iho_boundaries$"NAME" %in% ocean), ] data_sf <- data_to_sf(data) @@ -38,8 +43,7 @@ filter_by_ocean <- function(data, ocean) { ## Spatial filter ---- - inter <- suppressWarnings(sf::st_intersects(data_sf, iho_boundaries, - sparse = FALSE)) + inter <- suppressWarnings(sf::st_intersects(data_sf, iho, sparse = FALSE)) data[which(apply(inter, 1, any)), ] }