I'm trying to get a convex hull of point features in R.
library(tmap)
library(sf)
nc <- st_centroid(st_read(system.file("shape/nc.shp", package="sf")))
qtm(nc)
ch <- st_convex_hull(nc)
qtm(ch)
identical(nc, ch)
I'd expect the st_convex_hull
to contain polygon with convex hull. However it returns points that are not identical. How can I get the polygon instead?
You need to union the points into MULTIPOINTS
library(tmap)
library(sf)
nc <- st_centroid(st_read(system.file("shape/nc.shp", package="sf")))
qtm(nc)
ch <- st_convex_hull(st_union(nc))
qtm(ch)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With