Python scripts within gpsbabel

Why ?

As I'm a geek and I own a GPSr, I looked at what was possible in terms of homemade scripting solutions. It turns out that it was not what I expected. The first thing is that the command apt-cache search python gps does not return anything useful.

I first wanted to port an existing application written in php (see the ''moulinette'').

It basically analyzes your gps dumps and generates a file suitable for Google Earth with nice graphs, stats. The first step was then to have the needed data in my favorite language: python.

Instead of rewriting a frontend for gpx, I tried to see how easy it was to reuse code from gpsbabel. The software is written in C, and it seems that devs really want to keep it this way, with good old' ANSI C code. There is some skeleton code for building your own module, so I decided to learn this and how to integrate python from C code, at the same time. It turns out it's rather easy. Now, I use gpsbabel as a frontend that feeds my python module with data. Currently, this module outputs a Google Earth file, but this could be anything else...

The code is not very mature, in fact it's still in an early stage development, and I guess it will stay this way. But it could be useful to other people, so feel free to take it and modify it, everything is GPL ! Of course, I won't track upstream changes on a day to day basis, so expect some problems...

What ?

Ok, simply said, you can write a quick & dirty python script to manipulate your GPS data.

How to use it ?!

Simple, simply ask gpsbabel to use the pykml module as output, and give parameters to the script by following the module name by a list of key=value list. Ok, here I'm cheating as currently, I don't use any parameters, so you have to hack directly in the python script... This is far more convenient than having to modify C code and recompile everything...

Simple example ! Take this gpx dump from a flight at the Semnoz, uncompress it, and run:

$ PYTHONPATH=$PATHTOGPSBABEL gpsbabel -i gpx -f semnoz-parapente.gpx -o pykml -F pouet.kml

This will output a nice kml file suitable to use directly in Google Earth:

Output from pykml module of GPSBabel

Ok, you've convinced me, where can I download it ?! How do I build it ??

You have the choice (and choice is good (tm)): you can simply take a tarball that may be outdated. Or you could use the git repository but unfortunately, it's not up yet :o)

Then, you have to type these commands:

$ aclocal -Im4 && autoconf && ./configure && make

You may be forced to use the extra --with-python=/usr/bin/python2.5 to ask configure to use python 2.5 (yes, you need python 2.5 because it was easier for me)

Then, you're clear to go, but don't forget to set PYTHONPATH var correctly, or gpsbabel will use this nice mecanism for error handling called "Segmentation fault" :)