Re: [R] How extract the names of ID in SpatialPolygons object

From: Roger Bivand <Roger.Bivand_at_nhh.no>
Date: Sat 31 Dec 2005 - 04:00:55 EST


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@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@nhh.no

______________________________________________
R-help@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
Received on Sat Dec 31 04:16:40 2005

This archive was generated by hypermail 2.1.8 : Sat 31 Dec 2005 - 04:52:39 EST