Robert,
Great, thanks for pointing `raster::bind()` out as well. Guess I should
re-read the vignette periodically!
--Mel.
On 7/23/2016 5:04 PM, Robert J. Hijmans wrote:
The raster way would be:
library(raster)
m <- lapply(c("TZA", "UGA", "GHA"), function(x) getData("GADM",
country=x,
The raster way would be:
library(raster)
m <- lapply(c("TZA", "UGA", "GHA"), function(x) getData("GADM",
country=x, level=1))
m <- do.call(bind, m)
Robert
On Sat, Jul 23, 2016 at 4:10 AM, Bacou, Melanie wrote:
> Edzer, Rolf,
> Many thanks for the clarification!
> Just to
Edzer, Rolf,
Many thanks for the clarification!
Just to confirm that Rolf's `do.call()` example works for me using the
latest GitHub commit.
> m <- lapply(c("TZA", "ETH", "GHA"), function(x) getData("GADM",
country=x, level=1))
# with sp_1.2-3
> m <- do.call(rbind, c(m,
On 23/07/16 05:00, Bacou, Melanie wrote:
> Thanks! I wonder why the original syntax passing a list used to work (I
> believe).
It shouldn't have worked:
> rbind(list(1,2,3))
[,1] [,2] [,3]
[1,] 123
> rbind(1,2,3)
[,1]
[1,]1
[2,]2
[3,]3
>
> For a much longer
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 =
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]])))
Mel,
> m <- lapply(c("TZA", "UGA", "GHA"), function(x) getData("GADM",
country=x, level=1))
I get: (after GDAM downloads)
trying URL 'http://biogeo.ucdavis.edu/data/gadm2.8/rds/TZA_adm1.rds'
Content type 'unknown' length 1152781 bytes (1.1 MB)
==
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.
>