CityLab Congressional Density Index
CityLab has classified every U.S. congressional district based on the density of the hundreds of neighborhoods that make up each one.
We're releasing the full results — and the code used to produce the Congressional Density Index — to the public. The code is released under the MIT License, and the data under a Creative Commons Attribution-ShareAlike 4.0 International License. You're free to use and modify this work, provided you attribute the CityLab Congressional Density Index, and maintain a similar license on your use of the CDI.
To learn more about the CDI, read our methodology. You can also read the CityLab article by David Montgomery and Richard Florida introducing the preliminary findings: that Republican-held suburban seats are in particular danger in the 2018 congressional elections.
This repository contains all the code and data you need to reproduce our work. Of particular note:
citylab_cdi.csvcontains every district, its Congressional Density Index classification, and how its population is split up into different types of neighborhoods.
citylab_cdi_extended.csvis a more detailed version of
citylab_cdi.csvwith electoral history, pre-election forecasts, and more. The full column layout is specified in
district_class.Ris an R script that will calculate the neighborhood density makeup of each congressional district. (It relies on a variety of spreadsheets in the
datafolder, so you'll want to preserve the folder structure of this repository if you download and run it.)
cluster_analysis.Ris an R script that takes the output of
district_class.Rand performs a c-means clustering algorithm on it, grouping districts into distinct categories based on their neighborhood makeup.
shapefilesfolder contains a shapefile with every Census tract in the United States (not counting territories). This is necessary for
district_class.Rto run (so preserve folder structure), but might also be useful for other analyses!
The CityLab Congressional Density Index was developed by David H. Montgomery for CityLab.
If you have any suggestions, or find any bugs, please contact me or file a pull request.