更新时间:2023-02-26 18:31:03
事实证明:如果提供了一组点",则无需通过点猜测多边形或生成凸包-该命令将自动执行给您投影坐标的平均值.
It turns out that: if a group of 'Points' are supplied, then instead of guessing a polygon through the points or producing a convex hull - the command automatically gives you the mean of the projected co-ordinates.
但是,如果提供多边形,则会得到一个质心(与python脚本相同)-在我的python示例中,我缺少一个坐标:
However, if you supply a polygon then you get a centroid (the same as the python script) - in my python example I was missing one co-ordinate:
centroid = get_polygon_centroid(np.array([[-6424797.94257892, 7164920.56353916],
[-5582828.69570672, 6739129.64644454],
[-5583459.32266293, 6808624.95123077],
[-5855637.16642608, 7316808.01148585],
[-5941009.53089084, 7067939.71641507],
[-6424797.94257892, 7164920.56353916]]))
#polygon closed
#[-5875317.84402261 7010915.37286505]
因此运行此R脚本:
x = readWKT(paste("POLYGON((-6424797.94257892 7164920.56353916,
-5582828.69570672 6739129.64644454,
-5583459.32266293 6808624.95123077,
-5855637.16642608 7316808.01148585,
-5941009.53089084 7067939.71641507,
-6424797.94257892 7164920.56353916))"))
python_cent = readWKT(paste("POINT(-5875317.84402261 7010915.37286505)"))
r_cent = gCentroid(x)
plot(x)
plot(r_cent,add=T,col='red', pch = 0)
plot(python_cent, add=T,col='green', pch = 1)
一切都很好:
我在博客如果有兴趣.