#' Exclude areas from the survey domain
#'
#' Filter output of [gfdata::get_survey_sets()] to exclude sets within a given set of polygons.
#'
#' @param data A data frame from [gfdata::get_survey_sets()].
#' @param exclude_poly FIXME:
#' @param X FIXME:
#' @param Y FIXME:
#' @export
exclude_areas <- function(data, exclude_poly, X, Y){
if (class(exclude_poly) == "list"){
for (i in seq_along(exclude_poly)){
exclude_poly[[i]] <- as.data.frame(exclude_poly[[i]])
exclude_poly[[i]] <- select(exclude_poly[[i]], .data$geometry)
}
exclude_poly <- suppressWarnings(dplyr::bind_rows(exclude_poly))
exclude_poly <- sf::st_sf(exclude_poly)
exclude_poly <- sf::st_union(exclude_poly)
}
data %>%
sf::st_as_sf(coords = c(X, Y), agr = "constant",
crs = sf::st_crs(exclude_poly), remove = FALSE) %>%
sf::st_difference(exclude_poly) %>%
as.data.frame() %>%
dplyr::select(-.data$geometry)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.