fernando espindola
2005-Dec-30 16:14 UTC
[R] How extract the names of ID in SpatialPolygons object
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. Thank for all Fernando [[alternative HTML version deleted]]
Roger Bivand
2005-Dec-30 17:00 UTC
[R] How extract the names of ID in SpatialPolygons object
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