[R-sig-Geo] Problems with rbind(list(), makeUniqueIDs=T)

chris english englishchristophera at gmail.com
Fri Jul 22 23:24:43 CEST 2016


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)
==================================================
downloaded 1.1 MB

trying URL 'http://biogeo.ucdavis.edu/data/gadm2.8/rds/UGA_adm1.rds'
Content type 'unknown' length 1749955 bytes (1.7 MB)
==================================================
downloaded 1.7 MB

trying URL 'http://biogeo.ucdavis.edu/data/gadm2.8/rds/GHA_adm1.rds'
Content type 'unknown' length 164023 bytes (160 KB)
==================================================
downloaded 160 KB

> m <- rbind(m, makeUniqueIDs=T)
> head(m)
              [,1] [,2] [,3]
m             ?    ?    ?
makeUniqueIDs TRUE TRUE TRUE
> m
              [,1] [,2] [,3]
m             ?    ?    ?
makeUniqueIDs TRUE TRUE TRUE
> m <- lapply(c("TZA", "UGA", "GHA"), function(x) getData("GADM",
country=x, level=1))

## Now I have this data locally

> m
[[1]]
class       : SpatialPolygonsDataFrame
features    : 30
extent      : 29.32717, 40.44514, -11.7457, -0.9857875  (xmin, xmax, ymin,
ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84
+towgs84=0,0,0
variables   : 13
names       : OBJECTID, ID_0, ISO,   NAME_0, ID_1,        NAME_1, HASC_1,
CCN_1, CCA_1, TYPE_1, ENGTYPE_1, NL_NAME_1,       VARNAME_1
min values  :        1,  227, TZA, Tanzania,    1,        Arusha,  TZ.AS,
 NA,    01,   Mkoa,    Region,          ,
max values  :        9,  227, TZA, Tanzania,    9, Zanzibar West,  TZ.ZW,
 NA,    55,   Mkoa,    Region,          , Mjini Magharibi

[[2]]
class       : SpatialPolygonsDataFrame
features    : 58
extent      : 29.5715, 35.00027, -1.48214, 4.234466  (xmin, xmax, ymin,
ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84
+towgs84=0,0,0
variables   : 13
names       : OBJECTID, ID_0, ISO, NAME_0, ID_1,   NAME_1, HASC_1, CCN_1,
CCA_1,     TYPE_1,  ENGTYPE_1, NL_NAME_1, VARNAME_1
min values  :        1,  239, UGA, Uganda,    1, Adjumani,       ,    NA,
   ,   District,   District,          ,
max values  :        9,  239, UGA, Uganda,    9,    Yumbe,  UG.YU,    NA,
 41, Water body, Water body,          ,   Luweero

[[3]]
class       : SpatialPolygonsDataFrame
features    : 10
extent      : -3.255419, 1.19177, 4.738751, 11.1733  (xmin, xmax, ymin,
ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84
+towgs84=0,0,0
variables   : 13
names       : OBJECTID, ID_0, ISO, NAME_0, ID_1,  NAME_1, HASC_1, CCN_1,
CCA_1, TYPE_1, ENGTYPE_1, NL_NAME_1, VARNAME_1
min values  :        1,   87, GHA,  Ghana,    1, Ashanti,  GH.AA,    NA,
   , Region,    Region,          ,
max values  :        9,   87, GHA,  Ghana,    9, Western,  GH.WP,    NA,
   , Region,    Region,          ,

>

I'm a little puzzled as well, but "TZA", "UGA" & "GHA" seem to have found
their way to min/max values and presumably this is as it should be.
Chris





On Fri, Jul 22, 2016 at 11:55 PM, Bacou, Melanie <mel at mbacou.com> 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
>
> --
> Melanie BACOU
> International Food Policy Research Institute
> Snr. Program Manager, Spatial Data and Analytics
> Work   +1(202)862-5699
> E-mail m.bacou at cgiar.org
> Visit  www.harvestchoice.org
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list