R Language Introduction to Geographical Maps 50 State Maps and Advanced Choropleths with Google Viz


A common question is how to juxtapose (combine) physically separate geographical regions on the same map, such as in the case of a choropleth describing all 50 American states (The mainland with Alaska and Hawaii juxtaposed).

Creating an attractive 50 state map is simple when leveraging Google Maps. Interfaces to Google's API include the packages googleVis, ggmap, and RgoogleMaps.


G4 <- gvisGeoChart(CityPopularity, locationvar='City', colorvar='Popularity',
                   options=list(region='US', height=350, 
                                 colors:[\'red', \'pink\', \'orange',\'green']}")


The function gvisGeoChart() requires far less coding to create a choropleth compared to older mapping methods, such as map() from the package maps. The colorvar parameter allows easy coloring of a statistical variable, at a level specified by the locationvar parameter. The various options passed to options as a list allow customization of the map's details such as size (height), shape (markers), and color coding (colorAxis and colors).