Site icon R-bloggers

Combining Admin 1 Choropleths and Reference Maps

[This article was first published on R – AriLamstein.com, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

A new version of choroplethr (v3.4.0) is now on CRAN. It allows you to combine Administrative Level 1 choropleths with reference maps. For reference, this functionality has been present for US maps for a while now (1, 2). This update just extends that functionality to the Administrative Level 1 mapping function, admin1_choropleth. To do this, just set the parameter reference_map=TRUE.

This feature is most useful when zooming in on small regions. In these situations it is often difficult to understand “what you are looking at” with just a choropleth. Consider this example: population density in the Kansai region of Japan. Note that I used to live in the Kansai region of Japan, so I already have some familiarity with the region:

library(choroplethr)
library(choroplethrAdmin1)

?df_japan_census
data(df_japan_census)
df_japan_census$value = df_japan_census$pop_density_km2_2010

# prefecture names for kansai region in japan
kansai = c("mie", "nara", "wakayama", "kyoto", "osaka", "hyogo", "shiga")
admin1_choropleth(country.name = "japan", 
                  df           = df_japan_census, 
                  num_colors   = 4, 
                  zoom         = kansai)

I can name about half of the regions from memory, but that’s it. I expect that most of my friends wouldn’t get that far. Adding in a google maps layer helps people understand things much better:

 
admin1_choropleth(country.name = "japan", 
                  df           = df_japan_census, 
                  title        = "2010 Population DensitynKansai Region, Japan",
                  legend       = "People / km^2",
                  num_colors   = 4, 
                  zoom         = kansai,
                  reference_map = TRUE)

Here you can see that the Kansai region includes famous cities such as Osaka, Kobe and Kyoto. And the choropleth helps you understand that the prefectures that contain Osaka, Kobe and Kyoto are much denser than the other prefectures in Kansai. Incidently, I used to live in Tsu, on the eastern region of Kansai. It’s one of the most rural prefectures of Kansai. My jogging route used to literally go through rice fields!

Wrapping Up

If you wind up using this package in your work, please tweet me an image of your map (@arilamstein) – I’m always interested to see how my software is being used.

If you want help getting started with this package, this vignette should help. Also, my course Mapmaking in R with Choroplethr goes into considerably more detail.

The post Combining Admin 1 Choropleths and Reference Maps appeared first on AriLamstein.com.

To leave a comment for the author, please follow the link and comment on their blog: R – AriLamstein.com.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.