rbind of SpPolDFs
On Tue, 18 May 2010, Agustin Lobo wrote:
Thanks. I have to do it this way as the tables are inconsistent: BesosBoundary at data <- data.frame(Basin="Besos") TerBoundary at data <- data.frame(Basin="Ter") BesosBoundary <- spChFIDs(BesosBoundary, "Besos") TerBoundary <- spChFIDs(TerBoundary, "Ter") delme <- rbind.SpatialPolygonsDataFrame(BesosBoundary,TerBoundary) Nevertheless, as I have several of these shape files, I'm trying a loop. But while the following works:
i <- 1 basnom <- unlist(strsplit(bas[i], "Boundary")) basnom
[1] "Besos"
slot(BesosBoundary,"data") <- data.frame(Basin = basnom)
the following (which I need for using the names in an array) does not:
bas[i]
[1] "BesosBoundary"
slot(get(bas[i]),"data") <- data.frame(Basin = basnom)
Error in slot(get(bas[i]), "data") <- data.frame(Basin = basnom) : could not find function "get<-" am I doing something wrong or have I hitted an inconsistency?
The error message seems explicit. Use get() first to a temporary local object, do slot()<- on that object, and assign() back to bas[i]. Untried. Roger
Agus
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