Over the last few days, I have played around with ways to project three dimensional GPS track data onto photographs. My primary motivation was to use GPS track data that I had recorded on one of our recent scrambles to visualise the route that we had taken across a mountain’s ridge.

The problem is mainly one in finding the right perspective from which the photograph was taken and then transforming the track data appropriately to line them up with the image. Thanks to various python software packages, the task was not as difficult as it seemed at first. In particular, I used gpxpy to read the GPS data, the python bindings to the PROJ software to perform coordinate transformations, matplotlib for image loading and 3D visualisation, numpy for transforming the data, and pandas to wrap the data nicely.

Below you find the resulting picture of the Tryfan mountain with a projection of our scrambling route overlaid. I plotted the projected route on top of the photo, which resulted in slight issues with the stacking of objects in depth. For example, the approach path to the mountain, that is visible on the right-hand side of the image, is in reality behind the small ridge on the right and would be hidden from view from the camera’s position. Nonetheless, the alignment of the projected GPS track with the photo is quite accurate and reflects my understanding of the climbing route. Any inaccuracies are mainly due to slight misalignment of the virtual viewpoint of the projection to the actual camera position and orientation.

Our scrambling route across Tryfan's north ridge projected onto a photo of the mountain.
Our scrambling route across Tryfan’s north ridge projected onto a photo of the mountain.

The mountain in this image is called Tryfan and is located in Snowdonia, in North Wales, UK. We roughly followed the north ridge route, which is one of the truly classic grade 1 scrambles in Wales (and in all of the UK for that matter). It combines a small amount of exposure (as in air under your feet) with little objective danger, at least in good weather conditions, for a delightful day out. Highly recommended.

Future Work

In its current form of the technique, I spend most of the time manually trying to figure out the correct camera viewing angle, as well as iterating over how to transform (scale and shift) the projected data to match the image. The above could probably be automated by using techniques from computer vision, such as edge and control point detection, and (reasonably automatic) affine transformations. OpenCV and its python bindings look particularly promising for this, and it would be interesting to incorporate those tools. However, doing so would be beyond the scope of this weekend project. :-)