Introduction

La Vuelta Analytics is an analytical and geospatial platform to visualize, process and compare the history of La Vuelta a España between 2011 and 2026: 16 editions, 333 stages and more than 1,100 riders. It starts from GPX tracks and official classifications and turns them into interactive maps, terrain metrics, comparison tools and a historical profile for every rider.

The goal is that any fan can answer, in a couple of clicks, the questions that always come up while watching the race: have we seen this profile before? When was the last time the race came through here? Is this Vuelta harder than last year’s? How many times has this rider been on the podium?

The idea behind the project

Cycling generates a huge amount of data, but it usually ends up trapped in official PDFs that expire from one year to the next, static tables or route books that are hard to consult afterwards. The project started from a personal itch: I wanted a tool that really answered the typical debates among fans.

  • The geographic debate: “La Vuelta always goes to the same places” or “they forgot about this area this year”. Instead of going by gut feeling, you can analyze the real coverage: regions visited, stages outside Spain and, on the provinces map, when the race last passed through each territory.
  • Memory and shared routes: “When was the last time this climb was used?” Given a reference stage, the system computes spatial intersections to find which other stages in history shared at least 3 continuous kilometres of road with it.
  • The déjà vu of profiles: “I swear there was an almost identical stage a few years ago”. Every stage is compared against all the others and the closest matches are listed.
  • Head-to-head between editions: “This Vuelta is much harder than the previous one”. The comparator puts two years side by side: kilometres, elevation gain, hardness, stage types and both routes on the same map.
  • The protagonists: “How many stages has Roglič won?” Every rider has a profile with their record in the race, their general classification history and their career by year and team.

To make it work, I processed the official .gpx tracks with Python, computed real gradients, identified climbs and road sections with GIS libraries (GeoPandas and Shapely) and normalized the profiles so that stages more than a decade apart can be compared directly.

The starting point: the whole history at a glance

Everything starts at the Global Dashboard: one screen gives you the pulse of the entire history. It shows the accumulated metrics (editions, stages, kilometres and elevation gain), a map preview, geographic data such as the regions visited, and one card per edition with its miniature elevation profile. A strip under the indicators links to the riders directory, with the total number of riders and the one with the most stage wins.

La Vuelta Analytics global dashboard

Global Dashboard: full history, accumulated metrics, interactive map and miniature elevation profiles

In the server version, a dynamic filter narrows the charts down to a set of editions and lets you share that selection through a simple URL.

Discovering the geography of the race

Before comparing, it helps to understand how La Vuelta has moved over the years. The general map covers the whole history of routes, and the provinces view reveals a curious fact: when the race last passed through each Spanish territory.

Provinces map with the last visit of La Vuelta

Provinces map: the last time La Vuelta passed through each territory

Comparative analysis

This is the heart of the project. There are three tools, designed around those fan debates.

1) Similar stages: finding stages with the same DNA

Every stage is compared against the other 332 using a weighted similarity index built from six metrics: distance, total elevation gain, number of climbs, average climb gradient, maximum altitude and profile shape (normalized to 441 samples so that different lengths can be compared). The result is a similarity percentage and a ranking of the closest stages, regardless of the edition.

Comparing the profile shape alone wasn’t enough: a flat 190 km stage and a time trial can draw similar curves and have nothing in common. Combining several metrics makes each stage type naturally cluster with its own kind.

Elevation profile comparator

Similar stages: ranking by similarity percentage and profile comparison

2) Common route: roads that coincide over the years

One of my favourite features. Starting from a reference stage, the system detects which other stages in history share at least 3 continuous kilometres of road with it, using 50-metre buffers and spatial operations with Shapely. It makes the recurrence of certain climbs and roads across editions easy to see.

In the server version, each row expands and overlays only that stage and the reference one, with the shared section highlighted.

Detection of common sections between stages

Common route: reference stage against the selected one, with the shared section highlighted

3) Edition comparator: head-to-head between years

It confronts two editions in full detail: global KPIs (stages, distance, elevation gain, hardness in metres per kilometre), the hardest and longest stage of each, overlaid elevation and distance charts, the elevation distribution, the breakdown by stage type and a joint map of both routes with the exclusive and shared regions.

Head-to-head comparator between two editions of La Vuelta

Edition comparator: overlaid routes, KPIs and distribution by stage type

A closer look at each stage

Although comparisons are the soul of the project, every stage has its own page: route on an interactive map, dynamic elevation profile, automatically computed terrain metrics, the day’s podium and, at the bottom, the most similar stages in history with a direct link to each.

Stage detail with map and elevation profile

Stage detail: interactive map, dynamic elevation profile and terrain metrics

Team time trials

Team time trials (TTT) deserved their own treatment. There are 11 in the period, and the result belongs to the team, not to individual riders. That is why they are stored in a separate table, the stage page shows the team podium and the team standings, the edition’s stage list flags them with a TTT label, and they add no individual wins or podiums to any rider.

It looks like a minor detail, but it was a data modelling lesson: in a first version the teams were stored as if they were riders, which polluted the ranking with 40 “riders” that were actually teams.

The protagonists: riders ranking and profile

The riders directory is a searchable, sortable table with a Stages / General switch that changes both the numbers shown and the sorting criterion at once. Each rider has a profile with their record (stage wins, podiums and top-10s), their general classification history, the podiums achieved, the breakdown by stage type, their teams and their year-by-year career.

The general classification data (2,425 finishers from 2011 to 2026) comes from two different sources, a historical CSV and saved ProCyclingStats pages, and required a considerable amount of name normalization: upper-case surnames, particles, compound first names and aliases to avoid duplicates (“Eddie” and “Edward” Dunbar, for instance).

What’s behind the calculations?

  • Gradient calculation: the real elevation change between GPS points is computed, with percentile (P99) filtering to remove altimetry errors.
  • Climb detection: significant climbing sections are identified, and the maximum gradient (P99), the average gradient of the climbs and their total number are computed.
  • Geospatial analysis: buffers and operations with Shapely and GeoPandas to detect overlaps between historical routes.
  • Stage similarity: a weighted index of six metrics, each one’s relative difference normalized between 0 and 1.
  • Caching expensive results: the general maps, each stage’s common sections and the similar stages are computed once and stored on disk; recomputing the common sections of all 333 stages takes tens of minutes.

Architecture and technologies

The project strictly separates responsibilities: the mathematical and spatial calculations live in a services layer independent of the views, which makes maintenance, testing and reuse easier.

Technology stack

  • Backend: Django 5.2 with SQLite and a modular architecture of models, views and domain services.
  • Interactivity: HTMX to update charts and move between stages without reloading the whole page.
  • Geospatial analysis and GPX: GeoPandas, Shapely, gpxpy and geopy.
  • Data science: pandas and NumPy for elevation gain, altimetry normalization and percentile-based cleaning.
  • Visualization: Plotly for charts and Folium for maps, with a dark base map (Esri Dark Gray, with OpenStreetMap data).
  • Quality: a suite of 31 automated tests, Ruff for static analysis and django-environ for configuration.

Project structure

proyecto-lavuelta/
├── core/                         # Django configuration (settings, urls, context processors)
├── analytics/                    # Analytics app
│   ├── models.py                 # Edicion, Etapa, Ciclista, Equipo, results (individual and team) and general classification
│   ├── views.py                  # View controllers
│   ├── tests.py                  # Tests: pages, ranking, TTT, static export
│   ├── services/                 # Business logic decoupled from the views
│   │   ├── charts.py             # Plotly figures (profiles and comparisons)
│   │   ├── ciclistas.py          # Riders ranking and historical profile
│   │   ├── geografia.py          # Folium maps and common-section calculation
│   │   ├── gpx_processor.py      # GPX parsing, gradients (P99) and climb detection
│   │   ├── perfiles_similares.py # Stage similarity index
│   │   └── sparkline.py          # Miniature SVG profiles
│   ├── management/commands/      # Import, static export and precomputation
│   ├── templates/analytics/      # HTML templates
│   └── static/analytics/         # Custom CSS (dark theme) and JavaScript
└── manage.py                     # Django CLI

Deployment and demo

The application uses a static export strategy to be hosted on GitHub Pages without a Django server in production. The export_static command requests every page from the application itself and saves it as HTML: around 1,650 pages (dashboard, map, editions, stages, riders and comparator) plus their assets. It supports partial exports (only the comparator, only the riders…), a dry run and an automatic verification of internal links, which checks tens of thousands of links at the end of a full export.

The comparator also works in the demo, but precomputed: there is one page for each pair of editions (120 combinations), and the lists of similar stages and common routes come from data embedded in the page, which a small JavaScript renders when a stage is picked.

Live demo: https://andreslires.github.io/lavuelta-analytics-web/
Note: the demo is a static export. With no server, it does not include the dashboard’s dynamic edition filter, the manual side-by-side comparison of two stages, the maps of each shared section in “Common route” or the admin panel.

Next steps

It is a living project and there is still a way to go:

  • Full results for every stage: today there is a podium or top-10 for each stage; the goal is to bring in the whole classification, with abandonments and time-limit cuts. The general classification is already complete.
  • Teams across the years: unify under a single “historical team” the records of a team that changes its name from one year to the next.
  • More comparator in the demo: bring the manual comparison of two stages and the maps of each shared section to the static version, which currently need a server.

Conclusion

La Vuelta Analytics goes far beyond a list of stages. It is a way of rediscovering the history of the race from an analytical perspective: comparing editions, finding similar profiles, tracking roads that come back, measuring how demanding the routes really are and getting to know their protagonists.

It combines geospatial analysis, data engineering and interactive interfaces to turn GPX tracks and classifications into useful knowledge. What I enjoy most is that, in a couple of clicks, you can answer those questions that always come up when talking about cycling: “Have we seen this profile before?”, “Where has La Vuelta been lately?”, “Is this route really different from last year’s?”. Now those answers are there, visual and interactive.