Monday 18 March 2013

Putting geotagged photos into Google Earth with Python

The final product. You click on a pin and a balloon with the
image taken at that location pops up.
So I got a bunch of pictures at work that turned out to be Geotagged. "Pretty cool" I thought to myself, "but clearly I need to see these on a map to know where they were taken!" Deciding to leap before actually looking, I missed the fact that Picassa can generate KMZ files for use in Google Earth directly, and instead went about making a script to do it manually. Doing it like this does have the slight advantage of being able to control the output KMZ much more precisely - so you can have bigger pictures or different icons or show different info in the balloons.

To do this, I used a couple of third party libraries for Python. Simplekml is a package that lets you write kml and kmz files. Although there were a couple of things that seemed to be bugs, it worked pretty well.
To extract the GPS coordinates, I needed a package to read exif data. At first I tried to use PIL, but I couldn't get it to work on my work computer (didn't have a c compiler set up correctly) so I ended up using pyexiv2. The page said it was deprecated and I should use Gexiv2 instead. That seemed to add more complications, so I just used pyexiv and it worked fine (note I did this in Python 2.7, if I had used Python 3.x pyexiv2 wouldn't have worked).

This outputs a KMZ file which includes all the pictures zipped up within it. In other words, it's making a copy of all your pictures in a file that could get pretty big if you have lots of them. Anyway, without further ado, here is the script that goes through a given folder and generates a kmz file with the locations of each.

Wednesday 30 January 2013

"There's only one London." False: there are at least 20.

So I was wondering the other day, how big is the biggest London compared to the smallest London? The answer is that London, England is 140,931 times bigger than London, West Virginia. The chart above demonstrates this, along with the relative populations of all the other Londons I could find population data on.

Note that I found references to yet more Londons: New London, Indiana, New London, Maryland, London, Burgundy and New London, PEI are all apparently out there, but with elusive population counts. Please let me know if you know the population of any of these Londons. There are also a bunch of townships with London in the name, which I have not counted here. I also left out London Mills, Illinois, population 447 as of 2000.

A note on the numbers: I used the most recent available census result or estimate available for each of the Londons. I used metropolitan areas where available. For East London, I found all sorts of different numbers ranging from 135,500 to 1.4 million. The 880,000 I used is from here, which is apparently the city's own website.

Monday 21 January 2013

The value of football

Dots are sized according to 2011-2012 season revenue. Thank you to everyone that located the missing
team in the original map: the Redskins.
I finished the article on the value of hockey and I thought to myself "why not do it for football too?" So here we are.  Forbes has again compiled financial information on each of the teams, including their own valuations.

Wednesday 16 January 2013

The value of hockey

Map showing 2011-2012 revenue for the 30 NHL teams.
Well hockey's back, which got me thinking about the value of the teams, how much they make and how profitable (or unprofitable) they are. Are Canadian teams on significantly firmer financial grounds?

Fortunately Forbes has already done all the legwork.