5.7 KiB
Executable File
GPX Run Dashboard
Turn a GPX file and a background photo into a finished running dashboard in 9:16 story format: a map with an elevation-colored track, a large distance readout and a grid of key metrics.
The design borrows from the dashboards of Strava, COROS and Garmin, taking whatever works best from each of them.
What it does
- Reads the track points (latitude, longitude, time, elevation) from the GPX file.
- Computes distance, duration, pace and start/end times directly from the data.
- Crops the background photo to 9:16 and puts a dark gradient on top. The strength of the gradient adapts automatically to the brightness of the photo, so the text stays readable.
- Draws the track as a map. The line is colored by elevation (light purple for low, dark purple for high) and start and finish are marked.
- Renders the dashboard below it, with distance as the hero value and nine metric tiles.
The result is a PNG in 9:16 (2700 x 4800 px at 300 dpi), ready for Instagram and Strava stories or as a cover image.
Version 8 vs. version 9
The only difference is the elevation profile:
| v8 | v9 | |
|---|---|---|
| Map with elevation coloring | yes | yes |
| Dashboard and metrics | yes | yes |
| Elevation profile at the bottom | no | yes |
gpx_visualizer_v8.py is the compact version. gpx_visualizer_v9.py adds an
elevation profile over cumulative distance at the bottom (line plus area fill)
and moves the metric tiles up a bit to make room for it.
Everything else is identical in both scripts: same parameters, same logic.
Installation
Requires Python 3.9 or newer.
pip install -r requirements.txt
Or individually:
pip install gpxpy matplotlib numpy pillow
| Package | Used for |
|---|---|
gpxpy |
Parsing GPX files |
matplotlib |
Map, typography and layout |
numpy |
Distance calculation, elevation normalization |
Pillow |
Photo cropping, EXIF rotation, gradient overlay |
Usage
# Version 9 (with elevation profile)
python gpx_visualizer_v9.py \
--gpx run.gpx \
--photo sunrise.jpg \
-o dashboard.png
# Version 8 (without elevation profile), with extra metrics
python gpx_visualizer_v8.py \
--gpx run.gpx \
--photo sunrise.jpg \
--ascent 312 \
--avg-speed 11.4 \
--total-energy 742 \
--energy-cons 9.8 \
-o dashboard.png
Without -o the result is only shown in a window (plt.show()).
Parameters
| Parameter | Description |
|---|---|
--gpx |
Required. Path to the GPX file |
--photo |
Required. Path to the background photo |
-o, --output |
Output file (PNG). Without it, a preview window opens |
--distance |
Override the distance in km instead of computing it from the GPX |
--max-height |
Override the highest point in m |
--ascent |
Total ascent in m (not computed from the GPX) |
--pace |
Pace as text, for example 4:52 (otherwise derived from duration and distance) |
--start |
Start time as text, for example 18:04 |
--end |
End time as text, for example 18:52 |
--avg-speed |
Average speed in km/h |
--total-energy |
Total energy in kcal |
--energy-cons |
Energy consumption in kcal/min |
What comes from the GPX, what you have to pass in
Computed automatically from the GPX:
- Distance (haversine over all track points)
- Duration, and from that the pace
- Start and end time, converted to the local time zone
- Minimum and maximum elevation for the track coloring
- Elevation profile (v9 only)
Not part of standard GPX files, so they are passed as parameters:
- Total ascent (
--ascent) - Average speed (
--avg-speed) - Energy and energy consumption (
--total-energy,--energy-cons)
If a value is missing, the tile shows a placeholder dash. The tiles do not disappear, they stay in the layout as placeholders.
Design
- Background: Photo, center-cropped to 9:16, honoring EXIF rotation. The dark gradient at the top and bottom is calculated from the average brightness of the photo, so bright photos get more dimming.
- Map: At the top, without axes or frame. The track sits on top of a soft black shadow line so it stays readable on busy photos. The aspect ratio is corrected for the mean latitude, so the map is not distorted.
- Colors: A purple ramp for elevation (
Purples), light start marker (#ce93d8), dark finish marker (#4a148c), labels in#b39ddb. - Distance: The hero value at the top of the lower block, followed by a thin divider and a 3x3 grid of metrics.
- v9: Elevation profile at the very bottom, as a line with an area fill, showing only the left and bottom axis, kept subtle and transparent.
Notes
- Time zones: GPX timestamps are treated as UTC and converted to local time
for display. If your device writes local times without a timezone offset into
the GPX, start and end can be shifted. In that case just set
--startand--endmanually. - Missing elevation data: Points without elevation are treated as
0. That distorts the track coloring, but not distance or time. - Photos: A portrait photo that roughly fits the format works best. It will be cropped, and the crop is always centered.
- Multiple tracks or segments: All points are concatenated. Jumps between segments count as distance.
Project structure
.
├── gpx_visualizer_v8.py # Dashboard without elevation profile
├── gpx_visualizer_v9.py # Dashboard with elevation profile
├── requirements.txt
├── README.md # English
└── README.de.md # German
The short version
GPX in, photo in, finished running dashboard out. No server, no upload, no API: everything runs locally in a single Python script.