Exploring Congressional Districts using the Data Observatory


This post may describe functionality for an old version of CARTO. Find out about the latest and cloud-native version here.
Exploring Congressional Districts using the Data Observatory

The Data Observatory contains a wealth of information available for exploration and data augmentation. In this post we will look at an available dataset provided by the U.S. Census that is very much in the news: United States Congressional Districts.

First let's retrieve all of the U.S. Congressional Districts and display them in a map. Using the function OBS_GetBoundariesByGeometry we can populate a table with all of the geometries. We can find the tag we need for getting the districts from the [Data Observatory's catalog].

Steps to Create a Congressional District Map

  1. Create a new table in CartoDB
  2. Rename the table to us_congressional_districts
  3. Rename the name column to geoid
  4. Run the following query:


INSERT INTO us_congressional_districts(the_geom  geoid)
SELECT the_geom  geom_refs
  FROM OBS_GetBoundariesByGeometry(
         ST_MakeEnvelope(-179.5  13.4  -42.4  74.4  4326) 

If you switch to 'Map View' you'll see the United States covered in congressional districts. Now we can start exploring.

Where are the 10 smallest districts?

Here New York City takes the cake.

It has 9 of the top 10 smallest congressional districts by area. Number 10 is in the center of Los Angeles. If you're interested in recreating this [see] the SQL I used.

Where are the 10 largest districts?

Unsurprisingly we find that Alaska is the largest congressional district followed by Montana Wyoming and large chunks of other western states. I re-projected the data into a more compact format so it is easier to see all of the congressional districts in one view.

See the [SQL I used] to create that map. Or just download the .carto file on that map's public page.

10 potentially gerrymandered districts

The geometries of congressional districts are often in the news because of accusations of gerrymandering. The Washington Post highlights several districts which have highly irregular shapes (i.e. they're not compact in a mathematical sense). We list them here!

North Carolina's 1st 4th and 12th districts have long extended shapes that span large areas of the state:

##_NOT_FOUND_IMAGE_## https://eschbacher.cartodb.com/api/v1/map/static/named/tpl_eaf15c20_2431_11e6_b322_0ea31932ec1d/940/581.png?zoom=8&lat=35.5618901&lon=-78.5 ##_NOT_FOUND_IMAGE_##
North Carolina Congressional Districts

Chicago has a district the shape of ear muffs:

##_NOT_FOUND_IMAGE_## https://eschbacher.cartodb.com/api/v1/map/static/named/tpl_eaf15c20_2431_11e6_b322_0ea31932ec1d/940/581.png?zoom=11&lat=41.87&lon=-87.79 ##_NOT_FOUND_IMAGE_##

Maryland's 3rd district wends all across the central parts of the state as does Pennsylvania's 7th:

##_NOT_FOUND_IMAGE_## https://eschbacher.cartodb.com/api/v1/map/static/named/tpl_eaf15c20_2431_11e6_b322_0ea31932ec1d/940/581.png?zoom=8&lat=39.5&lon=-76 ##_NOT_FOUND_IMAGE_##

Texas' 21st and 33rd districts and Louisiana's 2nd:

##_NOT_FOUND_IMAGE_## https://eschbacher.cartodb.com/api/v1/map/static/named/tpl_eaf15c20_2431_11e6_b322_0ea31932ec1d/940/581.png?zoom=7&lat=30.8187111&lon=-94.2 ##_NOT_FOUND_IMAGE_##

Finally Florida's 5th district:

##_NOT_FOUND_IMAGE_## https://eschbacher.cartodb.com/api/v1/map/static/named/tpl_eaf15c20_2431_11e6_b322_0ea31932ec1d/940/581.png?zoom=8&lat=29.5&lon=-82 ##_NOT_FOUND_IMAGE_##

These were all captured with our Static Maps API from this map.

Use this map and its data by downloading this map's .carto file from its public page.

To create similar or even better visualizations you can watch our Data Observatory webinar as many times as you need to!


What's next?

Watch our blog for more about the Data Observatory or read more in our introductory post.

Happy open data mapping!