Value of coordinates() for a SpatialPolygonsDataFrame object?

淺唱寂寞╮ 提交于 2019-12-04 04:57:28

问题


I am trying to get a pseudo barycenter for polygons in a spatial polygon dataframe. Today I stumbled upon the coordinates function that actually returns something for a SpatialPolygonsDataFrame.

Unfortunately I found nothing in the help of coordinates about the value for SpatialPolygonsDataFrame. Could somebody tell me what these coordinates are?


回答1:


It is the polygon centroid. The source code is found here, look for function FindCG. The equations computed are equivalent to those found on wikipedia, but in addition deal with the special case of polygons with (near) zero area, and normalize polygon coordinates by the first point (to increase numerical precision and/or avoid overflow).




回答2:


Reading the definition of coordinates for SpatialPolygonsDataFrame I can see that it is actually the same than getSpPPolygonsLabptSlots as it retrieves the labpt slot, that is to say a convenient point to put a label for the polygon.

> selectMethod("coordinates",signature="SpatialPolygonsDataFrame")
Method Definition:

function (obj, ...) 
{
    .local <- function (obj) 
    {
        ret = t(sapply(slot(obj, "polygons"), function(i) slot(i, 
            "labpt")))
        dimnames(ret) = list(sapply(slot(obj, "polygons"), function(i) slot(i, 
            "ID")), NULL)
        ret
    }
    .local(obj, ...)
}


来源:https://stackoverflow.com/questions/29565769/value-of-coordinates-for-a-spatialpolygonsdataframe-object

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