Skip to content

Commit

Permalink
fix: subset polygons in iho by ocean names
Browse files Browse the repository at this point in the history
  • Loading branch information
ahasverus committed Feb 21, 2024
1 parent 50bc59d commit 1b4b511
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions R/filter_by_ocean.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ 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)


## 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)), ]
}

0 comments on commit 1b4b511

Please sign in to comment.