September 2009 Archives
Inspired by Stephen Taylor's post (and my own past project from Fall 2008), I set out to produce a website where people could navigate election results by riding, but also by poll.
I used cartographic data from the Geogratis.gc.ca website. I imported the Shapefiles to a PostgreSQL database with Postgis. Then, I processed results by polling divisions from the 2008 election, data available on the Elections Canada website. It was put in a separate table on the same database. A custom program in Python using the very handy libkml (a code library developed and supported by Google) took the data and outputted pretty KML code. It was packed as a KMZ and uploaded to my webspace. [E-mail me, if you want to exchange ideas on the code]
For instance, the Papineau riding (24048) can be accessed through this link:
The website requires the Google Earth plugin, available for Windows and Mac. It works very smoothly on my old computer (bought in 2003).
You could also download the individual KMZ files (they are in fact zip files, so on Windows you would rename them with .zip and unzip them with your usual utility). They are at: https://earth.smurfmatic.net/canada2008/polls/ridings/ . However, if I post updates (which I will), you won't see them.
A new grocery store on Victoria Avenue just opened its doors last week. The half basement shop offers a variety of organic (and non-organic too) produce. It may fit the look of a Westmount upscale boutique, but the prices shown for the basic stuff (tomatoes, apples, lemons) are at market price (similar to PA's price, comparatively lower than the nearby Metro).
On top of that, you also find a unique offering of Asian products (the owner Clara happens to be a food-loving Canadian Chinese) such as soy milk, bok choy and ramen noodles. They are also importing a type of pasta from Italy.
334A Avenue Victoria, Westmount
Speaking of young entrepreneurs, I found out that the newest my cup of tea shop is just next door:
Download the KMZ / Téléchargez le KMZ
Finally finished the first phase of my data visualization project for electoral donations to political parties. The data is for individual contributions during the 2008 election in Fall. Here is the KMZ file: contrib40_2009-09-11.kmz
Finalement, j'ai fini la première phase de mon projet de visualisation de données de contributions aux partis politiques. Les données sont pour les dons de particuliers lors de l'élection d'automne 2008. Voici le fichier KMZ: contrib40_2009-09-11.kmz
Here are a few examples of stuff that I found while fooling around... / Voici quelques exemples que j'ai trouvé en me promenant...
David Kilgour gives to the Conservative Party. We think it's _the_ David Kilgour, because wife Laura is also listed for the same postal code. For the notice, Kilgour was a former Jean Chrétien minister (originally was a Progressive Conservative). Retired as an independent in 2006 and known to be a Falun Gong sympathizer.
Michael Sabia, the Caisse de dépôt et de placement du Québec CEO, formerly a Bell Canada CEO, naturally gives to the Liberals.
Edit (2009-11-11): I completed the project a few days after describing it in this post. This link gives you an overview of what it does. Here is the web version (requires Google Earth plugin): https://earth.smurfmatic.net/canada2008/contributions/
Some time ago, I wrote a lot on this particular project without providing much specifics. This said project is the electoral contributions project.
The idea is pretty straightforward. Once a year, Elections Canada releases data on donations to political parties, whether it's from individuals or companies, directly to candidates or the party itself.
They have some database behind to power it, but none of it is open to the public. The only information available is under the form of webpages such as this one:
Also, you can click on the name of a contributor and find basic info such as the address where he sent his contribution from, specifically on this popup:
So, what if you got the data and tried to use the postal code to put every contribution on a map? It's been done in the States by the Huffington Post, the well-known web media outlet.
How to do it?
Then, parse the pages with a script. I wrote mine in PHP, because I didn't know better. I'll post it if there is interest for it. Then, the same script does the INSERTs to the PostgreSQL database. You can download this following database dump:
I chose the columns to be of a super permissive datatype, because the data in those webpages is surprisingly not very well normalized. You also find invalid postal codes and basically no practical way to identify two different donors with, say, the same name.
Then comes the interesting part that I've finished once but did not save anything useful, that is to visualize the contributions geographically with the postal code. I made a separate table called "postalcodes" which is a unique list of postal codes contained in contrib40, and the geographical point representing this postal code. I obtained the point coordinates using a script that called the Google HTTP geocoding service. It's for Postgis that I used PostgreSQL.
Now it's maybe the fun part, that is to fetch the data and make it into something useful, either using MapServer + Google Maps, or libkml (to generate a file for Google Earth).
Interesting, telling uses? Since we only have access to data up to the end of 2008, we could show the rise of the Liberals in the post-electoral months of November and December, when Stéphane Dion stepped down in favour of maybe-Michael Ignatieff. We can surely superimpose donation origin and actual voting patterns at the poll level.
If you have more visualization ideas, feel free to drop me a line: firstname.lastname@example.org. I'd like to hear your ideas, propositions. I think that this data ought to democratized, and using graphical methods like maps is one of the best methods nowadays.
S'il y a des luttes serrées sur l'Île de Montréal, ça risque fort bien d'être celles que se livreront le Parti libéral du Canada et le Bloc Québécois pour Papineau et Ahuntsic.
Ces deux circonscriptions du nord de la Ville de Montréal se sont promenés entre le bleu-vert et le rouge durant ces dernières années. Autrefois des châteaux-forts libéraux, ces circonscriptions sont maintenant des toss-ups sur l'Île de Montréal (avec aussi Verdun).
Papineau, qu'on voit ci-haut, c'est la circonscription de Justin Trudeau, fils de feu Pierre Trudeau. Trudeau Sr. avait d'ailleurs occupé la circonscription voisine de Mont-Royal, maintenant siège de l'ancien ministre de la Justice et prof à McGill Irwin Cotler. Papineau fût le siège du ministre Pettigrew du temps de Jean Chrétien. La Bloquiste Vivian Barbot n'aura siégé qu'un peu plus de deux ans aux Communes.
Si on regarde les résultats par scrutin, on voit bien que la portion Parc-Extension de Papineau vote en masse pour les Libéraux, alors qu'entre le Parc Jarry et le Parc Villeray (tout autour de la rue St-Denis), on préfère le Bloc. Plus loin à l'est, dans St-Michel, on a tendence à voter pour les Rouges.
Dans Ahuntsic, c'est le duel entre Maria Mourani (BQ) et Eleni Bakopanos (PLC) qui retient l'attention. Ces femmes se sont bataillées pour le siège pendant trois élections de suite et peut-être une quatrième à venir, si fédérales 2009 elles y ont lieu.
Ahuntsic est l'autre circonscription remarquablement divisée, avec une forte majorité d'électeurs votant pour les Libéraux vivant au sud-ouest de St-Laurent et une majorité d'électeurs pour les Bloquistes au nord-est.
Here is a demo for colouring the polls by their 2008 election result:
Only zoom levels 7 to 10 are coloured for now (it starts at 7). The colours represent the party that won any given poll territory, but in Canada, it's a first past the post system at the riding level (some ridings contain more than 100 polls).
It's running on my laptop, so the site might be down at any point, especially during the night. For the next step, I should be finding a way to add useful infos, like detailed results per poll/riding.