遵循以下问题:gCentroid shifting centroid towards concentration of points,但形状更复杂。
使用此SpatialPointsDataFrame,我使用gCentroid
计算了中心,但是将其放置在形状之外。
# c. = [dput'd data from link]
poly <- SpatialPolygons(Srl = list(Polygons( srl = list(Polygon(coords = coordinates(c.))), ID = 1)))
plot(poly)
axis(1)
axis(2)
points(rgeos::gCentroid(poly))
答案 0 :(得分:0)
我发现this软件包似乎可以解决问题。相关方法:https://blog.mapbox.com/a-new-algorithm-for-finding-a-visual-center-of-a-polygon-7c77e6492fbc
poly <- SpatialPolygons(Srl = list(Polygons( srl = list(Polygon(coords = coordinates(c.))), ID = 1)))
plot(poly)
axis(1)
axis(2)
points(rgeos::gCentroid(c.))
p <- polylabelr::poi(xx$long, xx$lat, precision = 0.01)
points(p)