I have the following data: https://ufile.io/p9s0le6g
...which consists of 485 lat/long observations. I ultimately want to calculate the surface area (in m2 or km2) of this figure. I wanted to create a polygon with the data points (the outer points) and then calculate the surface are. However, I cannot come up with a nice polygon.
My data points as coordinates look like:
I want a polygon which would look like that (or similarly):
Here is what I tried:
library(sp)
df <- read.csv('data.csv')
p = Polygon(df)
ps = Polygons(list(p),1)
sps = SpatialPolygons(list(ps))
plot(sps)
This results in (clearly not a nice polygon):
I also tried to implement the answer of Create polygon from set of points distributed but this results in just a rectangular for me:
Anyone an idea how I can optimize my polygon to get a figure which looks like the outer shape of my data points and how to then calculate the surface are of that optimized polygon?
Using concaveman
and sf
we can create a concave hull around your set of points:
library(sf)
library(concaveman)
pts <- st_as_sf(df, coords=c('LONG','LAT'), crs=4326 )
conc <- concaveman(pts)
conc %>% st_area()
# 4010443 [m^2]
library(ggplot2)
ggplot() +
geom_sf(data=pts, col = 'red', pch=3) +
geom_sf(data = conc, fill = NA)