gCentroid shifting centroid towards concentration of points

爱⌒轻易说出口 提交于 2019-12-11 17:36:49

问题


I have a SpatialPointsDataFrame defining SD boundary, however when I compute the center with gCentroid it's shifted.

c. = rgeos::gCentroid(c.) %>% as.data.frame()

Why isn't it plotting it at the center?


回答1:


It is because the mass of points is higher in the lower right corner. If you transform your object to a SpatialPolygons object (making it one shape) then it works:

poly <- SpatialPolygons(Srl = list(Polygons( srl = list(Polygon(coords = coordinates(dat))), ID = 1)))
gCentroid(spgeom = poly)

plot(poly)
axis(1)
axis(2)
points(gCentroid(poly)) 



来源:https://stackoverflow.com/questions/49736565/gcentroid-shifting-centroid-towards-concentration-of-points

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!