Thanks! I wonder why the original syntax passing a list used to work (I believe).
For a much longer (and unknown) list of SpatialPolygonsDataFrames could an approach using do.call() work instead? I tried but: > m <- do.call(rbind, m, makeUniqueIDs=T) Error in do.call(rbind, m, makeUniqueIDs = T) : unused argument (makeUniqueIDs = T) # This works though but takes an extra step > spChFIDs(m[[1]]) <- paste0("A", seq(length(m[[1]]))) > spChFIDs(m[[2]]) <- paste0("B", seq(length(m[[2]]))) > spChFIDs(m[[3]]) <- paste0("C", seq(length(m[[3]]))) > m <- do.call(rbind, m) > class(m) [1] "SpatialPolygonsDataFrame" attr(,"package") [1] "sp" --Mel. On 7/22/2016 5:53 PM, Edzer Pebesma wrote: > The correct call to rbind would be > > mm = rbind(m[[1]], m[[2]], m[[3]], makeUniqueIDs=T) > > with sp on CRAN this doesn't work; with the version on github it does. > > An alternative with sp from CRAN is to make the IDs unique by hand: > > spChFIDs(m[[1]]) <- paste0("A", seq(length(m[[1]]))) > spChFIDs(m[[2]]) <- paste0("B", seq(length(m[[2]]))) > spChFIDs(m[[3]]) <- paste0("C", seq(length(m[[3]]))) > mm = rbind(m[[1]], m[[2]], m[[3]]) > > > On 22/07/16 22:55, Bacou, Melanie wrote: >> Hi, >> I'm getting weird results trying to rbind a list of >> SpatialPolygonsDataFrames with R 3.2.1 and raster 2.5.8. I believe the >> code below used to merge all 3 country boundaries, but instead I now get >> a list with 6 elements (incl. 3 logical TRUE). Am I doing something wrong? >> >> Thx, --Mel. >> >>> library(raster) >>> m <- lapply(c("TZA", "UGA", "GHA"), function(x) getData("GADM", >> country=x, level=1)) >>> m <- rbind(m, makeUniqueIDs=T) >>> sapply(m, class) >> [1] "SpatialPolygonsDataFrame" "logical" "SpatialPolygonsDataFrame" >> [4] "logical" "SpatialPolygonsDataFrame" "logical" >> >>> sessionInfo() >> R version 3.2.1 (2015-06-18) >> Platform: x86_64-w64-mingw32/x64 (64-bit) >> Running under: Windows 7 x64 (build 7601) Service Pack 1 >> >> locale: >> [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United >> States.1252 >> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C >> [5] LC_TIME=English_United States.1252 >> >> attached base packages: >> [1] stats graphics grDevices utils datasets methods base >> >> other attached packages: >> [1] raster_2.5-8 sp_1.2-3 rj_2.0.5-2 >> >> loaded via a namespace (and not attached): >> [1] rj.gd_2.0.0-1 Rcpp_0.12.6 grid_3.2.1 lattice_0.20-33 >> > > > _______________________________________________ > R-sig-Geo mailing list > R-sig-Geo@r-project.org > https://stat.ethz.ch/mailman/listinfo/r-sig-geo [[alternative HTML version deleted]] _______________________________________________ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo