Value of coordinates() for a SpatialPolygonsDataFr

2019-03-01 12:15发布

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?

标签: r spatial rgdal sp
2条回答
\"骚年 ilove
2楼-- · 2019-03-01 12:22

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, ...)
}
查看更多
甜甜的少女心
3楼-- · 2019-03-01 12:31

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).

查看更多
登录 后发表回答