Skip to content
Python script to generate a high resolution heatmap from Strava GPX files
Python Shell
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
LICENSE
README.md
output_heatmap.png
requirements.txt
setup.sh
strava_local_heatmap.py

README.md

strava_local_heatmap.py

Python script to reproduce the Strava Global Heatmap (www.strava.com/heatmap) with local GPX data

Optimized for cycling activities 🚴

Check out github.com/remisalmon/Strava-local-heatmap-browser for an interactive version

Features

  • Minimal Python dependencies (matplotlib+numpy)
  • Fast (3x faster than gpxpy.parse())

Usage

Command-line options

usage: strava_local_heatmap.py [-h] [--gpx-dir DIR] [--gpx-year YEAR]
                               [--gpx-filter GLOB]
                               [--gpx-bound BOUND BOUND BOUND BOUND]
                               [--output FILE] [--zoom ZOOM] [--sigma SIGMA]
                               [--no-cdist] [--csv]

optional arguments:
  -h, --help            show this help message and exit
  --gpx-dir DIR         GPX files directory (default: gpx)
  --gpx-year YEAR       GPX files year filter (default: all)
  --gpx-filter GLOB     GPX files glob filter (default: *.gpx)
  --gpx-bound BOUND BOUND BOUND BOUND
                        heatmap bounding box coordinates as lat_min, lat_max,
                        lon_min, lon_max (default: -90 +90 -180 +180)
  --output FILE         heatmap name (default: heatmap.png)
  --zoom ZOOM           heatmap zoom level 0-19 (default: 10)
  --sigma SIGMA         heatmap Gaussian kernel sigma in pixels (default: 1)
  --no-cdist            disable cumulative distribution of trackpoints
                        (uniform distribution)
  --csv                 also save the heatmap data to a CSV file

⚠️ --zoom is OpenStreetMap's zoom level, first number after map= in www.openstreetmap.org/#map=

Example:
strava_local_heatmap.py --gpx-dir ~/GPX --gpx-year 2018 --gpx-filter *Ride*.gpx --zoom 13

For an explanation on the cumulative distribution function, see:
https://medium.com/strava-engineering/the-global-heatmap-now-6x-hotter-23fc01d301de

Output

heatmap.png
heatmap_zoom.png

heatmap.csv
See https://umap.openstreetmap.fr/en/map/demo-heatmap_261644 (contribution by @badele)

Setup

Run bash setup.sh && source virtualenv/bin/activate

Python dependencies

matplotlib==3.0.2
numpy==1.15.4

Other dependencies

Arch Linux (see here): sudo pacman -S tk

Projects using strava_local_heatmap.py

JeSuisUnDesDeux

You can’t perform that action at this time.