Yamakei.info

Notes on building reliable software with AI in the loop.

Trail Route Analytics

First-principles analysis of trail running and mountaineering performance using GPS-derived velocity models.

2015-12-01

Duration: Iterative over multiple yearsTools: Python, Flask, Heroku, GPS (GPX), Numerical analysis, Matplotlib, GitHub

Trail Route Analytics demo

Executive Summary

Trail Route Analytics is a Flask-based web app designed to analyze trail running, hiking, and mountaineering activities using raw GPS data. The goal was to understand an individual's performance characteristics and use that understanding to predict the time required to complete a given route. The app is deployable to Heroku for lightweight sharing and access.

This work predates modern deep learning approaches and intentionally focused on first-principles modeling, interpretability, and explainability. The system relied on velocity decomposition, normalization techniques, and the concept of a threshold velocity to characterize sustainable effort across varied terrain.


1. Problem

Estimating how long a trail route or mountain ascent will take is difficult due to:

  • Varying terrain and grade
  • Large differences between horizontal and vertical movement efficiency
  • Environmental factors such as altitude and surface conditions
  • Individual performance differences

Simple heuristics (distance-only or elevation-only rules) fail to capture these dynamics, while black-box statistical models provide limited insight into why a prediction is made.

I wanted a model that was:

  • Grounded in physics and physiology
  • Comparable across activities
  • Explainable to the user

2. Data and Constraints

The system operated on:

  • GPS track data (GPX)
  • Time-stamped latitude, longitude, and elevation samples

Constraints included:

  • No reliance on external sensors beyond GPS
  • High noise in elevation data
  • Irregular sampling intervals
  • Applicability across multiple activities (running, hiking, mountaineering)

The model needed to be robust to real-world GPS imperfections.


3. Approach

The core idea was to decompose movement into:

  • Horizontal velocity
  • Vertical velocity

Rather than treating distance and elevation gain independently, the system analyzed how performance changed as a function of grade.

Key steps included:

  • Segmenting GPS tracks
  • Computing instantaneous horizontal and vertical speeds
  • Normalizing velocity relative to grade
  • Identifying sustainable effort thresholds

This led to the concept of a threshold velocity, analogous to endurance thresholds in sports physiology, representing the maximum sustainable speed under given conditions.


4. Normalization and Threshold Velocity

Raw velocity varies widely with terrain. To make performance comparable:

  • Velocity was normalized across grades
  • Effort was analyzed as a function of incline
  • Sustainable performance envelopes were derived empirically

The resulting threshold velocity served as:

  • A compact representation of individual capability
  • A predictor for future route completion times
  • A way to compare performance across routes with different profiles

This approach favored interpretability over raw predictive accuracy.


5. Prediction Model

Using the derived performance characteristics, the system could:

  • Estimate total route time by integrating expected velocity over a route profile
  • Adapt predictions based on elevation distribution
  • Provide insight into where time would be gained or lost

The emphasis was on understanding the route, not just predicting a number.


6. What Shipped

The project delivered:

  • A reusable analysis pipeline for GPX data
  • Visualizations of velocity vs grade
  • A performance model based on threshold velocity
  • Route-level time estimation grounded in individual performance

The software was used to analyze personal trail and mountaineering activities and iteratively refined over time.


7. What This Project Demonstrates

This work highlights several enduring engineering principles:

  • First-principles reasoning over black-box modeling
  • Comfort working directly with noisy, real-world data
  • Emphasis on explainability and user trust
  • Ability to generalize across related domains

Although later iterations explored neural-network-based approaches, this artifact intentionally represents the non-ML, analytical foundation of the work.


8. Relationship to Later Work

Trail Route Analytics reflects an early but consistent theme in my work: extracting meaningful structure from complex systems while keeping models understandable.

In later projects, AI and machine learning accelerated implementation and expanded possibilities. However, the core discipline demonstrated here -- clarity of assumptions, interpretability, and domain understanding -- remains central to how I approach software design today.


References

  • Blog posts: https://trail-route-analytics.blogspot.com/
  • Source code: https://github.com/yama-kei/trail_analyzer