August 3, 2008

Worth a thousand words !

Reading a mail from a couple of friends who have been on a long trip gave me an idea. For someone geographically dyslexic like me, a map to show the places visited is essential. And more pictures to illustrate the text will not hurt. Like Alice said, what good is a story without pictures?

Why not write some code that will draw a map, plotting the places visited and then pull out some pictures from flickr tagged with the place name? With all the pictures, now it will be easy to make an illustrated travel journal in html or pdf (with latex).

Python as always made the task amazingly easy. Python's 'battery power' was in full display as I was able to use diverse libraries to do all the stuff. Google maps provided me with the latitude and longitude of each place through geopy, a geocoding toolbox for python. Then, the basemap toolkit of matplotlib allowed me to plot these coordinates on a map. For each place, I searched flickr for most interesting pictures tagged with the place name and then made a photosheet with 8 of the pictures. I used flickrpy to access the flickr API and then used PIL (Python Imaging Library) to combine the pictures.

Those interested can download the code here and look at it. Map is a class that draws a map with a list of places like this -

The class PhotoSheet pulls in the pictures from flickr and makes a sheet like this (for Istanbul).