Download Global Administrative Areas as RData files

Global Administrative Areas (GADM) is a spatial database of the location of the world's administrative areas. Files are provided as Google Earth KMZ, shapefiles (.shp), ESRI geodatabase and as I was exited to see: as .RData files.

Download or load directly from the website.
This will create an object called gadm:

R:
  1. library(sp)
  2. # let's take a small country...
  3. con <- url("http://gadm.org/data/rda/CHE_adm1.RData")
  4. print(load(con))
  5. close(con)

Conveniently, the object turns out to be a SpatialPolygonsDataFrame.

R:
  1. str(gadm, max.level=2)
  2. Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots
  3.   ..@ data       :'data.frame'27 obs. of  16 variables:
  4.   ..@ polygons   :List of 27
  5.   ..@ plotOrder  : int [1:27] 10 6 24 25 17 22 27 7 13 1 ...
  6.   ..@ bbox       : num [1:2, 1:2] 5.96 45.82 10.49 47.81
  7.   .. ..- attr(*, "dimnames")=List of 2
  8.   ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots

Add some data (from http://www.all-about-switzerland.info/swiss-cantons.html)

R:
  1. language <- c("german", "german", "german", "german","german","german","french","french","german","german","french", "french", "german", "french","german","german","german","german","german","german","german","italian","german","french","french","german","german")
  2.  
  3. gadm$language <- as.factor(language)
  4. col = rainbow(length(levels(gadm$language)))
  5. spplot(gadm, "language", col.regions=col, main="Swiss Language Regions")

nice!swiss_lang

No TweetBacks yet. (Be the first to Tweet this post)

4 thoughts on “Download Global Administrative Areas as RData files”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>