Map Virginia 2: VA Votes Project

The Problem

We want to make Virginia election data as accessible as possible for folks working to increase voter participation. The ability to query a database holding election results for the past decade or more and to compare results from year to year, including years with national elections and years with only local elections, would be most helpful.

The Plan

The voter precinct is the atomic unit for electoral districts in the United States. By storing election results in a database by precinct, it should be possible to create a wide range of database queries about the elections.

Creating the Database and Adding Voter Precincts

Assuming a PostGIS database setup as in described in Map Arlington 1: Extracting OSM Data for a Localized Map Server, create a database named va_votes with:

$ createdb va_votes
$ psql -d va_votes -c 'CREATE EXTENSION postgis'

Shapefiles for voter precincts are available in a github repository at:

https://github.com/vapublicaccessproject/va-precinct-maps-2016

which can be downloaded with:

$ git clone https://github.com/vapublicaccessproject/va-precinct-maps-2016

After changing to the va-precinct-maps-2016/shp directory and using PostGIS 2.0 pgsql2shp shp2pgsql Command Line Cheatsheet as a guide, I ran:

$ shp2pgsql -s 3857 vaprecincts2016 public.vaprecincts2016 > vaprecincts2016.sql
$ psql -d va_votes < vaprecincts2016.sql

Viewing the Database in QGIS

The PostGIS data can be viewed in QGIS by creating a connection to the database from QGIS:

Connecting QGIS to PostGIS database

and then browsing the layers in the Browser Panel. There is only one layer in this case, vaprecincts2016. Double clicking on vaprecincts2016 loads the layer into the Layers Panel and displays it:

VA Votes database in QGIS

The next task will be to begin assembling the data needed to reason about voters and elections.

Footnotes