Maps, Geocoding, and the R User Conference 2010

July 14, 2010

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

The R User Conference 2010 is scheduled for July 20-23, 2010.  Wanna know where?

Although there are more sophisticated methods of mapping with R the maps package makes mapping activities straightforward.  A bit of XML and Google Geocoding is enough to highlight the location of this years conference (or any other location of interest to you).  If you prefer to see this in living color – you can view it at github.

getDocNodeVal=function(doc, path)
   sapply(getNodeSet(doc, path), function(el) xmlValue(el))

  doc = xmlTreeParse(u, useInternal=TRUE)
  str=gsub(‘ ‘,’%20’,str)
  lng=getDocNodeVal(doc, “/GeocodeResponse/result/geometry/location/lat”)
  lat=getDocNodeVal(doc, “/GeocodeResponse/result/geometry/location/lng”)

  for (i in 1:10){points(loc[1],loc[2],col=heat.colors(10)[i],cex=i)}
  for (i in 1:10){points(loc[1],loc[2],col=heat.colors(10)[i],cex=i*.5)}
  title(main=’The R User Conference 2010′, sub=’July 20-23, 2010′)
  mtext(“NIST: Gaithersburg, Maryland, USA”)

loc=gGeoCode(‘100 Bureau Drive Gaithersburg, MD, 20899, USA’)

# World
map(‘world’, plot=TRUE, fill=TRUE);bullseyeEtc()

map(‘usa’, plot=TRUE, fill=TRUE);bullseyeEtc()

# State
map(‘state’,’Maryland’, plot=TRUE, fill=TRUE);bullseyeEtc()

UPDATE:  Thanks for the feedback in the comments below – there are a number of improvements suggested:
1)  Use URL Encode rather than just substituting out spaces.
2)  I ran this code without any problem on two machines – using R version 2.10.1 (2009-12-14) for Windows and XML version 2.8-1.  Other folks ran into problems with URL escape characters – but were able to replicate the functionality using the JSON package.  For more information…see the post at stackoverflow.

To leave a comment for the author, please follow the link and comment on their blog: R-Chart. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, 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.


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training




CRC R books series

Six Sigma Online Training

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)