OpenData + R + Google = Easy Maps

January 11, 2011
By

(This article was first published on Spatial Analysis » R, and kindly contributed to R-bloggers)

The release of the R package “googleVis” has made the production of interactive maps through Google’s Chart Tools a simple task. Ignoring the some basic data manipulation the below map was produced with these two lines of code:

library(googleVis)

Geo=gvisGeoMap(Map, locationvar=”Country”, numvar=”Percentage”,

options=list(height=350, dataMode=’regions’))

plot(Geo)

This map, although simple to produce, is nontrivial as it shows the percentages of 5-14 year olds in each country conducting child labour. You can download the data for it here, and the rest of the R code here.

Data: Map, Chart ID: GeoMap_2011-01-11-09-36-24


R version 2.12.1 (2010-12-16),

Google Terms of Use






If you print the “Geo” object you will get a load of code that you can then paste into your website. I am amazed by how straightforward it is, thanks to the clever people at Google some great programming from R contributors. It isn’t perfect (I think the Mercator projection is inappropriate here) but it’s a great start.

To leave a comment for the author, please follow the link and comment on his blog: Spatial Analysis » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , , , , , , , , ,

Comments are closed.