[R] How extract the names of ID in SpatialPolygons object
Roger Bivand
Roger.Bivand at nhh.no
Fri Dec 30 18:00:55 CET 2005
On Fri, 30 Dec 2005, fernando espindola wrote:
> Hi dear user,
>
> Anybody can tell me how extract the names of ID in SpatialPolygons
> object, I am try to link a data frame attributes with spatial polygons,
> but the row names of data frame is not the same that ID poligons.
The most generic way is to extract the "polygons" slot from your object
and then the "ID" from each member "Polygons" in turn - using sapply
because you want a character vector returned, one ID for each list member:
sapply(slot(mySpatialPolygons, "polygons"), function(x) slot(x, "ID"))
but there is an access function too:
getSpPPolygonsIDSlots()
which is just the above with a name.
Roger
>
> Thank for all
>
> Fernando
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-help
mailing list