You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks so much for your awesome package. I've been using it a lot.
I've been perplexed lately by some odd situations where the algorithm seems to ignore one or a few points when it's creating the polygon.
I've uploaded a small dataset of coordinates to the issue and I hope the code below provides a full reproducible example.
I've seen this issue with a number of point datasets recently. The data represent survey locations from a continental scale bird monitoring program, but for this example the geographic aspects of the points are irrelevant (I think).
library(tidyverse)
library(sf)
library(concaveman)
# import text file of coordinates
coords <- read.csv("coordinates_example.csv") %>%
st_as_sf(coords = c("X","Y"))
Running the concave() function on these points creates a polygon that does not intersect all points.
concave_poly <- concaveman(coords) %>%
mutate(in_poly = TRUE) #adds a column for following join
missed <- coords %>%
st_join(.,concave_poly,
join = st_intersects) %>%
filter(is.na(in_poly))
In this case, there are three points that are outside of the polygon. However, two of them are extremely close, such that a 1-unit buffer on the polygon includes them. So not a problem in this context, likely more an issue with the precision of the st_intersects() function. So I added a 1-unit buffer below, but there is still one point outside the polygon, and it's far outside. It seems to be completely ignored by the algorithm.
concave_poly <- concaveman(coords) %>%
st_buffer(.,1) %>% #just adds a 1-unit buffer - simplifies st_join
mutate(in_poly = TRUE) #adds a column for following join
missed <- coords %>%
st_join(.,concave_poly,
join = st_intersects) %>%
filter(is.na(in_poly))
# plot the polygon with the missing point in red
display <- ggplot()+
geom_sf(data = concave_poly)+ #concave polygon
geom_sf(data = coords,alpha = 0.3)+ #original points
geom_sf(data = missed,colour = "red")+ #points that do not intersect polygon
geom_sf_text(data = missed,
aes(label = point),
size = 3)+
labs(title = "red point is far outside the polygon")
display
This plot shows the red point that's completely missed by the polygon.
Thanks so much for your awesome package. I've been using it a lot.
I've been perplexed lately by some odd situations where the algorithm seems to ignore one or a few points when it's creating the polygon.
I've uploaded a small dataset of coordinates to the issue and I hope the code below provides a full reproducible example.
coordinates_example.csv
I've seen this issue with a number of point datasets recently. The data represent survey locations from a continental scale bird monitoring program, but for this example the geographic aspects of the points are irrelevant (I think).
Running the
concave()
function on these points creates a polygon that does not intersect all points.In this case, there are three points that are outside of the polygon. However, two of them are extremely close, such that a 1-unit buffer on the polygon includes them. So not a problem in this context, likely more an issue with the precision of the
st_intersects()
function. So I added a 1-unit buffer below, but there is still one point outside the polygon, and it's far outside. It seems to be completely ignored by the algorithm.This plot shows the red point that's completely missed by the polygon.
The text was updated successfully, but these errors were encountered: