简体   繁体   English

如何获得多边形的中心点,必定在这些多边形(R,sp)中

[英]How to get central points for polygons, necessarily in these polygons (R,sp)

How to get central points for polygons that would fall necessarily in those polygons? 如何获得必然落在这些多边形中的多边形的中心点? Just getting the centroid will fall outside the polygon for many not convex polygons. 对于许多非凸多边形,仅获得质心将落在多边形之外。

Ideally the polygons would be SpatialPolygons in R and the central points would also be returned as an sp object. 理想情况下,多边形将是R中的SpatialPolygons,并且中心点也将作为sp对象返回。

You can use GetCentralPoints from the spatDataManagement package . 您可以使用GetCentralPointsspatDataManagement包 That is derived from this answer somewhere else on the web. 这是从网上其他地方的答案得出的。

Executing the example would return: 执行该示例将返回:

plot(woods[1:5,])
# the centroids
plot(GetCentroids(woods[1:5,]),add=T)
# the central points guaranteed to be in the polygons
plot(GetCentralPoints(woods[1:5,]),add=T,col="blue")
legend("bottomright",legend=c("Centroids","Central points"),col=c("black","blue"),pch="+")

You get (note the bottom polygon) 您得到(注意底部的多边形)

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM