Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Azavea Compactness Stats
Azavea has extensive experience calculating and analyzing legislative district compactness. Generally, we have used four common compactness metrics known as Polsby-Popper, Schwartzberg, Area/Convex Hull and Reock. You can find background information on these metrics and why they were chosen in our past white papers on the topic.
Azavea calculated these four compactness measures for all 6,779 state legislative districts in the United States. This includes 1,954 State Upper districts and 4,825 State Lower districts for 50 states, Washington D.C. and Puerto Rico.
Data on state legislative districts was obtained from the 2014 U.S. Census Bureau Tiger Line shapefiles. This includes all up-to-date redistricted (from the 2010 Census) state legislative districts for the entire U.S. In addition to state legislative districts, the Census Bureau Tiger Line shapefiles include shapes that only exist for cartographic purposes, which were eliminated from the analysis.
To prepare the data for processing, all contiguous U.S. state legislative districts were re-projected in GIS software to Albers Equal Area Conic. This ensures that when calculating area and perimeter measures, each district has a minimal amount of distortion, so districts in different parts of the country can be accurately compared to one another. However, this projection still results in distortion for Alaska and Hawaii. So, each of those state's districts were re-projected to their respective state Albers Equal Conic projection.
The Polsby-Popper measure is a ratio of the area of the district to the area of a circle whose circumference is equal to the perimeter of the district.
The formula for calculating the Polsby-Popper score is:
where A is the area of the district and p is the perimeter of the district.
The Schwartzberg score is a ratio of the perimeter of the district to the circumference of a circle whose area is equal to the area of the district.
To generate the Schwartzberg score, first the circumference of a circle with an equal area of the district must be calculated. To do so, use the formula:
where A is the area of the district and r is the radius. With the radius calculated, use the following formula to generate the circumference (perimeter):
Finally, generate the Schwartzberg score using the following ratio:
where P is the perimeter of the district and C is the circumference (perimeter) of the circle with the same area. In this case, we have taken the inverse of the number so that it falls on a scale of 0 to 100.
The Area/Convex Hull score is a ratio of the area of the district to the area of the minimum convex polygon that can enclose the district's geometry.
To generate convex hull polgyons in PostGIS:
CREATE TABLE convexhull_table AS SELECT gid, geoid, ST_ConvexHull(districts_table.geom) AS geom FROM districts_table;
With convex hull polygons generated, the ratio can be calculated using the formula:
where A is the area of the district.
For Reock calculations, first a minimum bounding circle must be generated for each district. Using PostGIS:
CREATE TABLE mbc_table AS SELECT gid, geoid, ST_MinimumBoundingCircle(districts_table.geom) AS geom FROM districts_table;
Once minimum bounding circles are generated, the ratio can be calculated. The Reock score is a measure of the ratio of the district to the area of the minimum bounding circle that encloses the district's geometry.
where A is the area of the district.
All scores were multiplied by 100 for readability.
See our blog post for more information on calculating the ratio scores in PostGIS.