Latitude tracks of 2012

I wrote this a a few years ago for my website that I have now migrated to wordpress.

Soon after Google Latitude started I signed up for it and sporadically updated my location. This worked slightly better with more advanced phones, but until I got my hands on a Nexus S in Autumn 2010 this always stayed very patchy. Just before Christmas 2012 a friend pointed me to Google Takeout that allows to download all data Goggle has stored about you including the Latitude data, if you have signed up for it. I had previously wondered how I could display my annual travel and had dabbled with the possibility to download parts of my entire in kml format form within Latitude. This however looked like it would make the whole project much simpler. So, I downloaded my data and thought I would quickly make a little map.

The first disappointment was that the takeout data was in json format and looking at it was not easy … After searching around for a while I found this script that converted json to kml. At last I could see my track in Google Earth. Unfortunately, Latitude includes quite a bit of erroneous data. So, the next step was to find a program that allows to edit a gpx trace. Again, it took a while to find the right program that I liked, eventually I found gpsprune . Now, the problem was that the entire annual data was a bit large. I used gpsbabel to break down the data into days.

#!/bin/bash

FirstDay=2011-12-24
for day in `seq 0 366`
do

begindate=`date -d "$FirstDay +$(( ${day} ))days" +%Y%m%d`00
enddate=`date -d "$FirstDay +$(( ${day} +1 ))days" +%Y%m%d`00

echo "$day $begindate $enddate"

gpsbabel -t -i gpx -f ../latitude-ordered.gpx -x transform,trk=wpt,del  -x track,split,start=$begindate,stop=$enddate -o gpx -F ../split/$begindate.gpx

done

Finally, I could go through every day and delete points that were wrong. I soon noticed that Latitude keeps reporting the same wrong data. So, another was used to scrub out those points.

#!/bin/bash
GPSBABEL=/usr/local/bin/gpsbabel
file=$1


LAT=12.345 
LON=6.7890

LAT0=1.2345
LON0=67.8901

$GPSBABEL -i gpx -f $file  -x transform,wpt=trk,del  -x radius,distance=0.2K,lat=$LAT,lon=$LON,nosort,exclude -x radius,distance=0.2K,lat=$LAT0,lon=$LON0,nosort,exclude   -x transform,trk=wpt,del  -o gpx -F tmp.gpx

rm $file
mv tmp.gpx $file

exit

A few days (or weeks) later I had cleaned the entire data set and glued the traces back together with gpsbabel.

#!/bin/bash

touch join.gpx
# actually this needs to be file that has valid GPX but no points
# in it. Otherwise gpsbabel throws a wobbly. I simply copied the 
# first gpx file and then deleted all track points.

for file in *.gpx
do

echo $file
gpsbabel -t -i gpx -f $file -i gpx -f join.gpx   -x track,merge,title="2012" -o gpx -F join-tmp.gpx
mv join-tmp.gpx join.gpx

done
exit

I could finally look at the result in Google Earth. It is a good idea to reduce the number of points a little bit which is easily achieved with gpsbabel.

#!/bin/bash
GPSBABEL=/usr/local/bin/gpsbabel

$GPSBABEL -i gpx -f $1 -x transform,wpt=trk,del -x transform,trk=wpt,del    -x simplify,count=7500 -x transform,trk=wpt,del -o kml,lines=1,points=1,line_width=4,trackdirection=1,labels=1 -F simple.kml
$GPSBABEL -i gpx -f $1 -x transform,wpt=trk,del -x transform,trk=wpt,del   -x simplify,count=7500 -o gpx -F simple.gpx

exit

The final product still has a few glitches which are mainly due to me being a bit slow to switch on data roaming or because Latitude failed (I believe there are a few days in 2012 where this was the case for my account).

My tracklog of 2012

Advertisement

About Uli

Grown up in Kiel, now living in Reading.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s