Home > Mobile >  Creating polygons from sparse data in R
Creating polygons from sparse data in R

Time:03-08

I have a dataframe with coordinates for which I want to create polygons, the most normal is a polygon like the one I put in the first image:

enter image description here

But I'm looking for something different, more like this: enter image description here

As you can see, if the points are enough far, another polygon is created, is this possible in R? Thanks!

Here are the data csv

CodePudding user response:

I think you would find the concept of concave/alpha hulls relevant. There's an R package alphahull that may cover your need.

install.packages("alphahull")
library(alphahull)
fff <- readr::read_csv("data.csv")
dddd <- ahull(fff[,2:3],alpha = 0.01)
plot(dddd)

And in case you need to convert this output into a spatial data format, please see the following: https://babichmorrowc.github.io/post/2019-03-18-alpha-hull/

  • Related