Plotting GPS data

Sometimes going out for just a walk isn’t that easy and some extra motivation is needed. Luckily I had just that extra: going for a walk allowed me to get some rather important real-world data for the GPS tracking service I have been working for quite some time.

During those walks I had the idea to further use the recorded data. The forest was filled with paths and I thought it’d be great to map those. And maybe even have some kind of heatmap of the most traveled routes!
Work, studies, gaming and general procrastination kept me busy, but here it finally is:

The plot was generated by going through all the sequential data points and constructing line segments. First the WGS84 GPS coordinates were fetched from the database and projected to Mercier projection(this is a popular projection for maps) with pyproj. Additionally for two points to connect, the positional accuracy had to be better than 30 meters, the points had to be close enough(in pixels), and they had to be recorded within five seconds of each other. Lastly the projected coordinates were centered on a manually chosen point of interest. No scaling was required thanks to the suitable projection.  After the initial preprocessing the lines were simply drawn using the Python Imaging Library resulting in the plot above. No darker magic required.

But while the plot looks great already, I though I could do better by adding a real heatmap effect using blended lines. This would have been quite hard / computationally expensive with PIL, so I changed to OpenGL. A real-time renderer also allowed the manipulation of zoom and panning, this was nice to have. So, after a bit of fiddling I had a nice mesh composed of 136 502 line segments.

The blending mode required by the heatmap produced some artifacts on segment intersections(see full-size images), but this was somewhat fixed by using multisampling. Better but much harder fix would have been to actually tessellate the vertices that represent the lines and correct those cases for good. See the following approximating diagram:

Bonus: an earlier image with two different projections(ETRS-TM35FIN and Gauss-Kruger) drawn on top of each other. Please don’t mind the (f)ugly thumbnail image; couldn’t quite figure out how to create one manually.

No comments: