Open Data + Open Source:

Mapping electoral districts &
MP voting records

International Open Data Day 2016

Rebecca Bartlett

GIS & Digital Resources Librarian / @bec_bart

Jen Whitney

Systems Librarian, Integration & Emerging Technologies / @toastncheez

Open Data Book Club

Monthly meetup hosted by Open Data Ottawa / @OpenDataOttawa

Open data enthusiasts get together to explore datasets and tools for mining, analyzing, visualizing data

Theme for October 2015 was electoral data

Our goals? Learn about open data, explore Leaflet, expand library's GIS service offerings

Parliamentary Data

OpenParliament.ca

Not an official government site ("not even sort of")

Aggregates data from Parliament of Canada pages

PARLINFO, Hansard, LegisINFO

For developers: a JSON API, bulk data download

GIS Data

GeoGratis.ca

"Find free maps, data, and publications to use without restriction" from Natural Resources Canada

Dataset used: Federal Electoral Districts 2011

Electoral district shapefile also available from Statistics Canada but GeoGratis specifically cites Open Government License - Canada

Putting it together

PostgreSQL

Load bulk data download into Postgres.app

Query MP details (name, photo, riding, party) & associate with federal electoral district identifier

Aggregate vote activity in second session of 41st Parliament

In order to join to GIS data, deduped after aggregation so 1 entry per FED

QGIS

Simplified geometry of electoral district shapefile to speed up data loading in final map

Joined queried MP data to shapefile using electoral district identifier

Exported as GeoJSON file for mapping with Leaflet

...except that didn't work so ran QGIS KML through CartoDB to generate functioning GeoJSON

Leaflet

Leaflet is an open-source JavaScript library
for mobile-friendly interactive maps

Jen: all code, no cartography

Leaflet

Leaflet is an open-source JavaScript library
for mobile-friendly interactive maps

Rebecca: all cartography, very little code

Leaflet

Initialized with CartoDB Positron basemap

Loaded GeoJSON data file

Electoral districts styled according to party, with pop-ups showing MP details

Slider control filters MPs by vote participation

Issues

UTF-8 encoding problems (ô, é, etc.)

Mapping MP Vote Activity

http://cu-library.github.io/mp-activity

Software, etc.

Postgres.app, a Mac app for PostgreSQL databases

QGIS geographic information system

Leaflet JavaScript library for custom online mapmaking

CartoDB online mapping tool & basemap provider

Atom source code editor

git version control system

Github, a platform for code sharing & and collaboratve development

Open Data Websites

Municipal, regional, provincial, and territorial open data websites in Canada

http://bartlettr.github.io/opendatawebsites/

Thanks!

rebecca.bartlett@carleton.ca / jennifer.whitney@carleton.ca