在 R 中,如何在点 sf 对象上运行 st_convex_hull 函数? [英] In R, how do I run st_convex_hull function on point sf object?

查看:29
本文介绍了在 R 中,如何在点 sf 对象上运行 st_convex_hull 函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 R 中获得点特征的凸包.

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)

我希望 st_convex_hull 包含带有凸包的多边形.然而,它返回不相同的点.我怎样才能得到多边形?

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?

推荐答案

你需要将点并入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)

这篇关于在 R 中,如何在点 sf 对象上运行 st_convex_hull 函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆