Block Equivalency to Shapefile Conversion

Block Equivalency Files: A Concise Format for Redistricting Plans

Luke McKinstry
DistrictBuilder
5 min readOct 4, 2021

--

Redistricting plans are often communicated through a block equivalency file. In this format, each census block in a state (a census block is the smallest and most detailed geographical statistical area measured in the US Census) is given a label with its assigned district. This can be a Congressional district, state legislative district, or local city council district. Take the following example from the top 5 lines from the block equivalency file from the North Carolina House of Representatives. The BLOCKID is the unique identifier for the geographic block assigned by the census (these are also commonly referred to as FIPS codes or GEOIDs, a useful guide to understanding the Census hierarchy is available here), and the second column refers to the legislative district the block is assigned to. In this example, SLDL means “state legislative district lower” which makes sense because the North Carolina House of Representatives is the lower state legislative chamber.

top 5 lines of a block equivalency file for a redistricting plan

Note: on rare occasions, census blocks will be split in a redistricting plan. In these instances, the Census Bureau requests the block be designated to one district for tabulation purposes.

Let’s say you receive a block equivalency file and you want to view it as a map. As shown above, the file does not include the geographic shape information for each block to render it in GIS or another mapping program. So you will need to find the geometry files for the corresponding blocks, and then join the block equivalency files to them, using the unique block identifier (“BLOCKID” in the sample file shown above) as the key field for the join.

DYK: you can directly upload a Block Equivalency File to DistrictBuilder to view a redistricting plan. Check out this blog for the easy steps:

Find Geographic Data for Census Blocks

For Congressional and state legislative redistricting, you will probably want to find the block geography file for a particular state. You can find the latest & most up-to-date block-level geometry files here on the US Census Bureau website. These files will download as zipped (.zip) shapefiles, meaning you can open them in GIS software or using geospatial packages in your scripting tool of choice (like GeoPandas in Python). If you find block files in another source — like geojson — you can load them directly into GIS or a scripting language, or you can research how to convert them to a shapefile first before following the instructions laid out below.

For local redistricting (like a city council), you may be able to find a geography file of census blocks for the location in a local open data portal (for help searching available data portals try this catalog) if one is available, or by contacting the local GIS or city planning office. Often for smaller cities, this information will be maintained by the county, not the city. As an alternative, you can always download the state block-level geography file and use GIS or a script to remove all the blocks that do not fall within your target locality.

Join Block Equivalency Files to Shapefiles

Once you have the block-level geography file for your location, you can perform the join operation with the block equivalency file. The key field for the join will be the unique block identifier (census FIPS code).

For joining the data using QGIS, follow this example: https://www.qgistutorials.com/en/docs/performing_table_joins.html

For joining the data in Python using GeoPandas, you will perform an attribute join. A full example is shown below:

First, make sure Python’s GeoPandas library is installed on your system.

Next, implement the following steps in a Python script to produce a zipped shapefile with each Census block assigned its corresponding district from the block equivalency file.

Python scripts are a great way to accomplish a variety of tasks. And there is a powerful set of libraries for geospatial data processing — starting with but not limited to GeoPandas — to help you along the way, often in just a few lines of code. While you can run the above Python code on your local machine, you can also carry out this process in a Google Colab notebook, which is a browser-based tool to run Python code in a Jupyter notebook environment in the cloud.

View Districts from a Joined Block Equivalency File in GIS

Now that you have merged the block equivalency file to the block geometry, you can view the districts from the original redistricting plan in GIS or a similar tool. Here is a quick way to inspect your new file in QGIS: Select your layer (this will be the file you created in the previous steps) and select properties to open the layer properties menu.

Settings in the layer properties menu of QGIS to view map data categorically by the assigned district.

In this window, select the symbology tab, and at the top of the central menu change the map layer to show categorized data. Working down the menu, change the value to the field showing the unique district identifiers (in our example this was “SLDL” column for the North Carolina House State Legislative Districts), and then we suggest setting the color ramp to random colors unless you have a different visual display in mind. Finally, click classify and you should see all the unique district identifiers values assigned a color. Then click apply to close the properties window and see the district's colors onto the original map.

A redistricting plan for the North Carolina House of Representatives rendered in GIS after merging the block equivalency file with a shapefile of the census blocks.

If you have any questions about DistrictBuilder and drawing redistricting maps please contact districtbuilder@azavea.com. Follow our Twitter page @DistrictBuilder where we will be providing regular updates.

--

--

Luke McKinstry
DistrictBuilder

Software Engineer of multi-service cloud-native web apps; Previously wrote about the @ciceroapi and @districtbuilder for @azavea