Redistricting

Statto Software is proud to have created the QGIS Redistricting Plugin, the first completely free desktop redistricting package.

Most desktop redistricting software costs thousands of dollars. Online redistricting software has some interesting functionality, but largely focuses on the United States and doesn’t give you the power of a full GIS software package.

The QGIS redistricting plugin works with the most up-to-date version of QGIS and contains all of the features you need to successfully redistrict a file.

Download

Currently, you can download the QGIS plugin from github. While you are welcome to clone the repository, downloading as a zip file will let you easily install the plugin.

Installation

Open QGIS. Find the Plugins menu in the top menu bar. Select Manage and Install Plugins. A dialog box should appear. Select Install plugin from ZIP file on the left hand side of the dialog box. Follow the on-screen instructions. The plugin should install.

QGIS Redistricting Plugin Features

  • Plan manager allows you to create multiple plans from the same shapefile
  • Population, target population, and deviation tracked for each district
  • Assign target populations, desired number of districts, and track any number of variables by district on the file
  • Support for both numerical and text electorate names
  • Support for any vector format used by QGIS
  • Support for up to two population fields with different tolerances (for Australian federal redistricting)
  • Allows for custom fields with custom display values
  • Export attribute table and field crosstabs to CSV
  • Lock completed districts
  • Custom select tools: select by geography, flood fill district
  • Find district tool lets you jump and zoom easily to a district
  • Slider-based district selection avoids clunky drop-down boxes
  • District eraser tool
  • Preview and undo last tools
  • Works internationally, not just with United States-based data
  • Full integration with QGIS – create district atlases, style finished districts, label layers, drape other layers on your target layer or over an OpenLayers plugin (OSM, Bing Maps, Google Maps)

Getting Started

  • Download the files you will need to redistrict and unzip them. These will likely be shapefiles or MapInfo files provided by your local government. Any file type will do, as long as the file contains the population.
    • Australia: Shapefiles and MapInfo files are available from the Australian Bureau of Statistics. At the time of writing, you will want the 2016 SA1 mesh blocks downloads page, preferably with ESRI Shapefiles.
    • New Zealand: 2018 Mesh blocks can be downloaded from the NZ Stats Datafinder.
    • United States: With 2020 Census data yet to be released, the plugin was tested using 2010 tab block files with population and housing units appended from https://www2.census.gov/geo/tiger/TIGER2010BLKPOPHU/. You will need to know the FIPS Code of the state you want to download. For instance, to download the information for Arizona, you would download the file with _04_ in the file name. You can also download a tab block file and append the data manually, or your state of interest may have produced better shapefiles or geodatabases, but this will be the easiest way for you to get started.
    • If you know of census information for any other countries which redistrict, please get in touch and the information will be added here.
  • Open the plugin through the plugin > redistricter menu. The redistricting panels should appear on the right hand side of the QGIS window.
  • Open the vector file you want to redistrict to the project. If you haven’t used QGIS before, you can do this by navigating to the Layer > Add New Layer > Add Vector Layer menu on the top menu bar, and then follow the on-screen instructions.
  • At this point, the layer should appear on your screen and in the layer panel. You may want to familiarise youself withyour layer’s attribute file, especially to make sure it contains a population column. Right-click on the layer name on the layer panel and select “Attribute Table…” from the drop-down menu. This will open the attribute table, which is a database containing all of the information associated with each polygon on the map. You will want to look through the table and find the population column. You may want to note if any current districts appear on the file as well, or if there are any columns representing geographies.
    • For U.S. census files, counties will generally appear as their FIPS Code ID instead of their name.
  • Click on the “Plan Manager” button at the top of the redistricting panel. A dialog box should appear with no active plans. Click “Create New Plan.” The redistricting plan box should appear.
  • Plan Name is a name you can give the plan to make it easy to find when you come back to it.
  • Layer to District is the name of the file you want to create districts for. If nothing appears here, make sure you properly added your file to the QGIS project.
  • Number of Districts is simply how many districts you will be splitting your file into. For instance, if you will have 88 electorates, type in “88” here.
  • Equal Population Tolerance lets you know if you have hit your population target for a given district. For instance, if your target population is 1,000 and you have a tolerance of 2%, you could have between 980 and 1,020 people in your district and the district will still be assumed to be okay. The software will calculate these numbers for you, and turn the district’s attribute table row green when you’re within this range. For most jurisdictions this number will be between 1-3%. For U.S. federal districts, these must be created down to the person, so this number will be 0%.
    • You are allowed to create up to two population fields with different tolerances (intended for use with Australian federal redistricting.)
  • District Field is required and is the column on the file you will be using to store which district each polygon is in. Unless you are starting from a previous districted file, most files do not come with this column pre-appended, so you can create it using the “Create New Field” button.
  • Data field allows you to add custom aggregate fields to the redisticting attribute table. The more fields you add, the slower performace will be.
  • Create Map Styles From Districts is useful when creating a new plan, as it will automatically style your map for you. For new users, a “styled map” will automatically colour the map for you (though it will initially start out all one colour if you have created a new map, as the entire map will start with an unassigned district.) It is automatically unchecked when you load a new plan since it assumes the map is already styled. You can see which colours are assigned to which districts both in the layers panel and in the redistricting attributes table.
    When you are ready to redistrict, click OK. QGIS may freeze briefly – don’t worry, it’s processing a lot of information!

Assigning Districts

  • Once you’ve got your plan set up and ready to go, your main workflow will be assigning districts by selecting polygons on the map and then clicking the update selected polygons button on the redistricting panel. Here’s a typical workflow:
    1. Select polygons of interest using one of QGIS’ select tools. The main select tool is on the attributes toolbar and has four different ways for you to select a feature, and the plugin has three ways of selecting built in.
      • You can select individual polygons, or select polygons by freehand, select all polygons within a polygon you yourself draw on the screen, or select all polygons within a specific radius of the mouse cursor. You will probably use “Select Features by Polygon” or “Select Features by Freehand” the most, depending on your preferred input method.
      • You can also select different geographies, depending on your file’s attributes structure, using the “Select by Geo” button on the redistricting panel.
        • An example of “Select by Geo” is where you have a county column on a U.S. map and you want to select all the polygons in the county. Make sure the county column is selected in the “Geographic Selection Field” box, click on “Select by Geo”, and then click on a polygon within your county of interest. The entire county should be selected. You can also assign if you want to select the entire geography, only unassigned parts, or only parts within the active district
      • The flood select tool selects all adjacent polygons with the same district number (up to the first 16,000.) It is useful for selecting small areas completely surrounded by other districts.
      • The “find” tool will select the current active district and zoom to that district.
    2. Make sure you have the correct active district assigned by sliding the district bar or using the +- buttons on the redistricting panel.
    3. If desired, preview the change by clicking the “preview” button. You will be able to see how the population will change if you confirm the assignment.
    4. Click the “Update Selected Polygons” button and wait. Small selections usually update instantly, while large selections (multiple counties) can take several minutes. The redistricting attribute table will update with the changes. If you’ve
    5. If you don’t like your most recent change, you can click the “undo” button.
  • You will typically repeat those steps until all of your districts have reached their target population.

Tips and Tricks

  • Downloading the OpenLayers plugin will let you add an OpenStreetMap, Google Map, or Bing Maps layer to your QGIS project. If you add one of these layers to your project (via the Web menu), add transparency to your redistricting layer (right-click on the layer name in the layer panel, select Properties…, go to the Symbology tab (typically open automatically), click the down arrow next to “Layer Rendering”, and set the opacity to ~50%), and make sure the OpenLayers layer is on the bottom (click and drag on the layer panel), you can easily see where you’re redistricting over a map of the area.
  • Under the Properties… > Labels tab, you can set each polygon’s label to be the number of people in that polygon, which can be very helpful when you’ve almost completed a district but need to ensure the population is balanced.
  • The “Select on Map” button allows you to select the active district by clicking any district on the map.
  • The “Flood Select” tool selects all connected polygons with the same assigned district. It can be very slow on large data sets, however it’s very useful for cleaning up artifacts, for instance when freeway medians are included in block files.
  • If you have a jurisdiction which uses names instead of district numbers, you can assign the proper names using the Toolbox > Assign Electorate Names dialog box.

    A successfully completed redistricting plan for the state of Connecticut.

Migrating from other software
Most questions about the software come from users who have used other redistricting software, especially online software. If you’ve had experience with other software, the following may be a bit different at first:

  • You have to select districts before assigning them. Online software allows you to “paint” districts which update immediately. The QGIS plugin allows you to select and preview districts, so you have to use a separate button to assign the precincts – this is the intended design.
  • “Select by Geo” controls the geographic hierarchy. Other software lets you click on, for example, a US County, and all districts in that county will be assigned to the active district. In the QGIS Plugin, you select geographies from the “Select by Geo” drop-down tool and then clicking on the map. All polygons within the selected geography will be selected. If your map does not contain a county field, you will not be able to select counties! This is the intended design, as the plugin has been designed to allow you to redistrict a singular layer in order to promote flexibility with plans around the world.
  • You may find the plugin a bit slower than you’re used to. The plugin has been optimised, but other software, especially online software, updates close to automatically. Some features may take several seconds to execute.

See also
You may also be interested in the beta of QGIS Automated Redistricter, which generates automated redistricting plans. However, this plugin is both relatively slow and not very “smart” in terms of generating districts of equal population size.

Credits
The QGIS Redistricting Plugin was developed by John Holden. Special thanks goes out to Moussa Dia at William & Mary, who not only tested one of the original versions of the software but wrote the first training manual; Robert Rose at the William & Mary Center for Geospatial Research; the William & Mary Election Law Society for their support; and Zach Alexopoulos and Blake Esselstyn, who helped put the plugin through its paces and have contributed substantially to the testing of the product.