Skip to content

Instantly share code, notes, and snippets.

@jkinred
Created December 14, 2013 20:04
Show Gist options
  • Save jkinred/7964185 to your computer and use it in GitHub Desktop.
Save jkinred/7964185 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import datetime
from igc2kmz.igc import IGC
garmin = IGC(open('blackheath_blackville_garmin.igc'))
compeo = IGC(open('blackheath_blackville_compeo.igc'))
g_track = garmin.track()
c_track = compeo.track()
# If the time of the compeo tracklog is within +5/-5 seconds of the time of the
# garmin tracklog, then use the compeo height
for i,t1 in enumerate(g_track.t):
for j,t2 in enumerate(c_track.t):
if t2 >= t1-5 and t2 <= t1+5:
dt = datetime.datetime.fromtimestamp(g_track.t[i])
# Only use values which aren't bogus
if g_track.ele[i] <= 3048:
# HHMMSS LAT LONG 'A' 00000 00ALT
print('B%02d%02d%02d%sS%sEA00000%05d' % (dt.hour, dt.minute, dt.second, garmin.o[i]['lat'], garmin.o[i]['lon'], g_track.ele[i]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment