Skip to content

Python script to generate a high resolution heatmap from Strava GPX files

License

Notifications You must be signed in to change notification settings

j-hiller/Strava-local-heatmap

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

145 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Python script to generate a high resolution heatmap from Strava GPX files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.1%
  • Shell 0.9%