Search code examples
rmapsisogooglevis

Incorrect ISO codes in gvisGeoChart?


I just started using googleVis in R, and am running into some trouble. I want to make a choropleth map of the departments of Honduras; here's my code:

map_me <- data.frame(prov=c("HN-AT","HN-CH","HN-CL","HN-CM","HN-CP","HN-CR",
                            "HN-EP","HN-FM","HN-GD","HN-IB","HN-IN","HN-LE",
                            "HN-LP","HN-OC","HN-OL","HN-SB","HN-VA","HN-YO"),
                     x=c(0.47,0.32,0.31,0.25,0.24,0.41,0.40,0.38,0.43,0.29,
                         0.17,0.25,0.33,0.17,0.19,0.39,0.21,0.31))
g <- gvisGeoChart(map_me,locationvar='prov',colorvar='x',
                  options=list(region="HN",dataMode="regions"))
plot(g)

In the browser window that pops up, the map is correctly zoomed-in on Honduras and the color scale in the legend shows the right limits (0.17-0.47). I think I have the correct ISO 3116-2 codes, based on the Wikipedia entry, but it seems to be having trouble connecting my data to the map locations.

Any ideas?


Solution

  • When all else fails, read the vignette. It turns out I needed to set the correct resolution option:

    g <- gvisGeoChart(map_me,locationvar='prov',colorvar='x',
                      options=list(region="HN",resolution="provinces"))