Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dealing with points in sf data #5

Open
eric-pedersen opened this issue Sep 27, 2018 · 0 comments
Open

Dealing with points in sf data #5

eric-pedersen opened this issue Sep 27, 2018 · 0 comments

Comments

@eric-pedersen
Copy link
Owner

Do we want to allow for points and develop MRFs for them?

Our best idea so far is to use a Voronoi tessellation to turn a given point set into a polygon set, but with non-convex point sets, we get odd issues. Basically, points that are far apart but at the edge of the area can be connected by this.

library(sf)
library(ggplot2)
set.seed(1)
#simulate some new data that falls in a crescent shape
new_data = data_frame(x = rnorm(600),y=rnorm(600))%>%
  filter(x^2 + y^2 <=1)%>%
  filter((x-0.2)^2 + (y-0.2)^2 >0.6)%>%
  st_as_sf(coords= c("x","y"))

ggplot(new_data) + geom_sf()

test1

#Create a Voronoi tesselation that we can get adjacency from
new_voronoi <- st_combine(new_data) %>%
  st_voronoi()%>%
  st_cast() 

#Plot it plus the original data
ggplot(new_voronoi) +geom_sf() + geom_sf(data=new_data)

test2

#We can clip this to the convex hull easily, but how do we deal with the tails connecting?
new_voronoi %>%
  st_intersection(st_convex_hull(st_combine(new_data)))%>%
  ggplot() +
  geom_sf()+
  geom_sf(data=new_data)

test3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant