I have a GPX from my Strava archive that looks like this (I've snipped away most of the track points for brevity; I can share the full file if needed), where the first <trkpt>
has no lon
or lat
attributes:
<?xml version="1.0" encoding="UTF-8"?>
<gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxdata="http://www.cluetrust.com/XML/GPXDATA/1/0" creator="Wahoo ELEMNT BOLT" version="5.8">
<metadata>
<link href="https://gotoes.org/strava/Combine_GPX_TCX_FIT_Files.php">
<text>GOTOES STRAVA TOOLS</text>
</link>
<time>2019-08-31T09:02:36Z</time>
</metadata>
<trk>
<type>Other</type>
<trkseg>
<trkpt>
<ele>31.2</ele>
<time>2019-08-31T09:02:36Z</time>
<extensions>
<gpxdata:temp>0</gpxdata:temp>
</extensions>
</trkpt>
<trkpt lon="24.93841" lat="60.16992">
<ele>31.2</ele>
<time>2019-08-31T09:02:37Z</time>
<extensions>
<gpxdata:temp>29</gpxdata:temp>
</extensions>
</trkpt>
<trkpt lon="25.34622" lat="60.86568">
<ele>117.4</ele>
<time>2019-08-31T13:00:17Z</time>
<extensions>
<gpxdata:temp>25</gpxdata:temp>
</extensions>
</trkpt>
</trkseg>
</trk>
</gpx>
$ python3 heatmap.py --width 1280 /tmp/test/test.gpx -o out.png
Traceback (most recent call last):
File "heatmap.py", line 1272, in <module>
main()
File "heatmap.py", line 1250, in main
config.fill_missing()
File "heatmap.py", line 1199, in fill_missing
self.shapes = list(self.shapes)
File "heatmap.py", line 813, in read_file
for trkseg in track.segments():
File "heatmap.py", line 115, in _parse
point = TrackLog.Trkpt(elem.attrib['lat'], elem.attrib['lon'])
KeyError: 'lat'
It probably happens because the first track point doesn't have latitude or longitude attributes (see GPX above).