Skip Navigation
Trulia Logo

Trulia Blog

Choroplethr Version 1.7.0

Today I am pleased to announce several significant changes to the choroplethr package for R. If you deal with visualizing geographic data in R, you might find these changes to be useful. You can get the latest version of the package by typing the following from the R console:


US Maps Now Include Hawaii and Alaska as Insets

Creating a choropleth map in R where Alaska and Hawaii appear as insets is a challenge. I have implemented a solution to this and it is now the default behavior when you call the functions ?choroplethr or ?choroplethr_acs with a data.frame with all 50 states. Here is an example:



choroplethr(df_pop_county, “county”, title=”2012 County Population Estimates”)


Previous versions of choroplethr did not render Alaska or Hawaii at all. For those who are interested in the technical details: choroplethr first renders the continental US, Alaska and Hawaii as three separate images and then combines them. If you are interested in the code, please type



and look at the examples. Some additional bookkeeping is required to have all three maps use the same scale.

Support for World Map Choropleths

The most requested feature for choroplethr has been support for country-level choropleths. Today I am happy to announce that choroplethr version 1.7 implements such support. This is a new direction for choroplethr and I hope to refine it as I get feedback from the community. Here is an example on how to use it.


df = data.frame(region=country.names, value=sample(1:length(country.names)))

choroplethr(df, lod="world")


A New World Map

I originally attempted to simplify the creation of world choropleths by using the world map that ships with the maps package. However, this map is quite old, and even contains the USSR as a country. This means that modern data cannot be bound to the map, since modern data does not list the USSR as a region. To address this choroplethr now ships with a world map from Natural Earth Data. This map is not without its own problems, though: the resolution of the map seems to have made smaller countries such as Singapore disappear. For details type:





I hope to continue to improve choroplethr’s support for world maps.

An Introduction to GIS for R Programmers

These improvements to choroplethr required me to learn a great deal about mapmaking outside the context of R. In order to help other R programmers make similar contributions I created a page on the choroplethr wiki titled Mapmaking for R Programmers. If you are interested in using R for a customized mapmaking project, this article might be useful for you.