identify_obs_in_polygon | R Documentation |
This function determines whether points (observations) in a given data frame are located inside a specified polygon.
identify_obs_in_polygon(
coords_df,
polygon_df,
strictly,
opt = "keep",
cvars = c("x", "y")
)
identify_obs_in_spat_ann(
coords_df,
outline_df,
strictly,
opt = "keep",
cvars = c("x", "y")
)
coords_df |
A data frame containing the coordinates of the observations.
Must contain columns specified in |
polygon_df |
A data frame containing the coordinates of the polygon's vertices.
Must contain columns corresponding to those specified in |
strictly |
A logical value indicating whether to consider only points strictly inside the polygon ( |
opt |
A character string specifying the operation to perform on identified points.
Options are "keep" (default), "remove", or any other string to create a new column in |
cvars |
A character vector specifying the variable names in |
outline_df |
A data.frame as returned by |
The function can be configured to strictly consider points within the polygon or to include points on the border. Additionally, the function allows for either keeping or removing the identified points, or marking them based on their position relative to the polygon.
A modified version of coords_df
based on the operation specified in opt
.
# Example data frames
coords_df <- data.frame(x = c(1, 2, 3), y = c(3, 2, 1))
polygon_df <- data.frame(x = c(1, 2, 3, 1), y = c(1, 2, 3, 1))
# Identify and keep points inside the polygon
inside_points <- identify_obs_in_polygon(coords_df, polygon_df, strictly = TRUE)
# Identify and remove points inside the polygon
outside_points <- identify_obs_in_polygon(coords_df, polygon_df, strictly = TRUE, opt = "remove")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.