Solved – US heatmap using zipcodes

data visualizationggplot2r

We are attempting to create a US heatmap using only zipcode and corresponding values using R. While there are a number of examples that use lat and long data for creating such maps, is there one that will accept zipcodes and colour the corresponding regions on a map ? Preferably using some package that will produce presentation quality images (ggplot2, etc). Thanks in advance, – Raj.

Best Answer

Zip codes are not a good level because strictly speaking zip codes are assigned to streets and hence the map is actually a line file rather than polygon.

For mapping purpose, try zip code tabulation areas (ZCTA) by Census Bureau. You can find mapping resources in the link. For most zip codes, it's safe to attribute them the corresponding ZCTA, though lone zip codes may still exist (largely due to the volatility of the postal zip code system and special zip code like @PeterFlom mentioned in the comment). You may find some crosswalk files between zip code and ZCTA (like this) to better recode your data.

Also, see this thread for some technical hints on using R to plot zip code maps.