library(sf)
# Create example sf object
points <- st_sfc(st_point(c(0,0)), st_point(c(1,1)), st_point(c(2,2)), st_point(c(0,2)))
sf_points <- st_sf(geometry = points)
# Calculate the convex hull
convex_hull_result <- convex_hull_sf(sf_points)
# Plot the result
plot(sf_points, col = 'blue', pch = 19)
plot(convex_hull_result, add = TRUE, border = 'red')
Run the code above in your browser using DataLab