参数解释:
concavity为infinite的时候就是凸多边形围栏,越小越显示细节
library(concaveman)
library(dplyr)
library(purrr)
library(sf)
library(tmap)
data(points)
polygons <- concaveman(points)
polygons
#> Simple feature collection with 1 feature and 0 fields
#> Active geometry column: polygons
#> geometry type: POLYGON
#> dimension: XY
#> bbox: xmin: -122.0844 ymin: 37.3696 xmax: -122.0587 ymax: 37.3942
#> epsg (SRID): 4326
#> proj4string: +proj=longlat +datum=WGS84 +no_defs
#> polygons geometry
#> 1 POLYGON((-122.0809 37.3736,... MULTIPOINT(-122.08441 37.38...
polygons2 <- map(unique(points$k),
~ concaveman(points[points$k %in% .,])
) %>%
map2(unique(points$k), ~ mutate(.x, k = .y)) %>%
reduce(rbind)
tm_shape(points) +
tm_dots(col = "k", size = 0.1,