Source: American Community Survey, 2011 5-Year Estimate
This map was inspired by a similar map found on Wikipedia. I wasn’t wild about the diverging color scale, so I thought it would be a fun challenge to recreate.
Finding the shapefiles was easy; I used the U.S. National Atlas 1:1,000,000 scale dataset, conveniently packaged in my U.S. Atlas repository. I reprojected the shapefiles to the California Albers projection using ogr2ogr:
ogr2ogr \
-f 'ESRI Shapefile' \
-t_srs 'EPSG:3310' \
tracts.shp \
shp/ca/tracts.shp
I used both the census tracts and the county shapefiles, since drawing county boundaries makes the geography more familiar.
Getting the population density per census tract was harder. I knew the data was available as part of the Census Bureau’s American Community Survey, but the American FactFinder is quite onerous. It takes almost twenty steps to find and download the data!
I mean, does that seem like too many steps to anyone else? How about a simple URL where I can substitute a year and a state FIPS code and just download the data directly without fighting through ridiculous wizards? Anyway, assuming you didn’t die of old age while folllowing those instructions, you should now have a ACS_11_5YR_B01003_with_ann.csv file which has the data.
Lastly, all we have to do is join the population data with the shapefile using topojson -e
. (See the TopoJSON command-line reference for full details.)
topojson
-e ACS_11_5YR_B01003_with_ann.csv \
--id-property GEOID,GEO.id2 \
-p population=+HD01_VD01,area=+ALAND \
-s 1 \
--width 960 \
--margin 10 \
-o ca.json \
-- tracts.shp counties.shp
The resulting TopoJSON file has the 2011 estimated population of each census tract as the population
property, and the land area in square meters as the area
property. Dividing one by the other and converting to square miles, we get the desired map!