• Stars
    star
    358
  • Rank 118,855 (Top 3 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 9 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Create a visually appealing poster from your GPX tracks

CI Format License MIT

GpxTrackPoster

Create a visually appealing poster from your GPX tracks - heavily inspired by https://www.instagram.com/p/Behppx9HCfx/

Usage

First of all, you need directory with a bunch of GPX files (e.g. you can export all your tracks from Garmin Connect with the excellent tool garmin-connect-export, or use StravaExportToGPX, or use runtastic, or use nrc-exporter to convert the activities in a Strava or Runtastic or Nike Run Club export zip file to GPX or GPX files).

You will need a little experience running things from the command line to use this script. That said, here are the usage details from the --help flag:

Get data from strava is ok now:

create_poster --from-strava strava.json --year 2020 --title "Running" \
    --athlete "Florian Pigorsch" --special 4110886680(strava id)

Only you need is change the strava config How to get strava config

usage: create_poster [-h] [--gpx-dir DIR] [--output FILE]
                     [--language LANGUAGE] [--localedir DIR] [--year YEAR]
                     [--title TITLE] [--athlete NAME] [--special FILE]
                     [--type TYPE] [--background-color COLOR]
                     [--track-color COLOR] [--track-color2 COLOR]
                     [--text-color COLOR] [--special-color COLOR]
                     [--special-color2 COLOR] [--units UNITS] [--clear-cache]
                     [--workers NUMBER_OF_WORKERS] [--from-strava FILE]
                     [--verbose] [--logfile FILE]
                     [--special-distance DISTANCE]
                     [--special-distance2 DISTANCE] [--min-distance DISTANCE]
                     [--activity-type ACTIVITY_TYPE] [--with-animation]
                     [--animation-time ANIMATION_TIME]
                     [--heatmap-center LAT,LNG] [--heatmap-radius RADIUS_KM]
                     [--heatmap-line-transparency-width TRANSP_1,WIDTH_1, TRANSP_2,WIDTH_2, TRANSP_3,WIDTH_3]
                     [--circular-rings] [--circular-ring-color COLOR]
                     [--circular-ring-max-distance DISTANCE]

optional arguments:
  -h, --help            show this help message and exit
  --gpx-dir DIR         Directory containing GPX files (default: current
                        directory).
  --output FILE         Name of generated SVG image file (default:
                        "poster.svg").
  --language LANGUAGE   Language (default: english).
  --localedir DIR       The directory where the translation files can be found
                        (default: the system's locale directory).
  --year YEAR           Filter tracks by year; "NUM", "NUM-NUM", "all"
                        (default: all years)
  --title TITLE         Title to display.
  --athlete NAME        Athlete name to display (default: "John Doe").
  --special FILE        Mark track file from the GPX directory as special; use
                        multiple times to mark multiple tracks.
  --type TYPE           Type of poster to create (default: "grid", available:
                        "grid", "calendar", "heatmap", "circular", "github").
  --background-color COLOR
                        Background color of poster (default: "#222222").
  --track-color COLOR   Color of tracks (default: "#4DD2FF").
  --track-color2 COLOR  Secondary color of tracks (default: none).
  --text-color COLOR    Color of text (default: "#FFFFFF").
  --special-color COLOR
                        Special track color (default: "#FFFF00").
  --special-color2 COLOR
                        Secondary color of special tracks (default: none).
  --units UNITS         Distance units; "metric", "imperial" (default:
                        "metric").
  --clear-cache         Clear the track cache.
  --workers NUMBER_OF_WORKERS
                        Number of parallel track loading workers (default:
                        number of CPU cores)
  --from-strava FILE    JSON file containing config used to get activities
                        from strava
  --verbose             Verbose logging.
  --logfile FILE
  --special-distance DISTANCE
                        Special Distance1 by km and color with the
                        special_color
  --special-distance2 DISTANCE
                        Special Distance2 by km and color with the
                        special_color2
  --min-distance DISTANCE
                        min distance by km for track filter
  --activity-type ACTIVITY_TYPE, --activity ACTIVITY_TYPE
                        Filter tracks by activity type; e.g. 'running'
                        (default: all activity types)
  --with-animation      add animation to the poster
  --animation-time ANIMATION_TIME
                        animation duration (default: 30s)

Heatmap Type Options:
  --heatmap-center LAT,LNG
                        Center of the heatmap (default: automatic).
  --heatmap-radius RADIUS_KM
                        Scale the heatmap such that at least a circle with
                        radius=RADIUS_KM is visible (default: automatic).
  --heatmap-line-transparency-width TRANSP_1,WIDTH_1, TRANSP_2,WIDTH_2, TRANSP_3,WIDTH_3
                        Define three transparency and width tuples for the
                        heatmap lines or set it to `automatic` for automatic
                        calculation (default: 0.1,5.0, 0.2,2.0, 1.0,0.3).

Circular Type Options:
  --circular-rings      Draw distance rings.
  --circular-ring-color COLOR
                        Color of distance rings.
  --circular-ring-max-distance DISTANCE
                        Maximum distance for scaling the track lengths (in
                        given units).

Example:

create_poster --from-strava strava.json --type circular
create_poster --type grid --gpx-dir "my-tracks" --language "de" --year 2015 --title "Running" \
    --athlete "Florian Pigorsch" --special race1.gpx --special race2.gpx --special race3.gpx

create_poster --type github --gpx-dir "my-tracks" --language "de" --title "Running" \
    --athlete "Florian Pigorsch" --special-distance 10 --special-distance2 10 --special-color yellow --special-color2 red

creates a nice poster (poster.svg) of the GPX tracks in the directory my-tracks (see above).

Selection of Tracks

create_poster tries to load all GPX files in the specified directory (option --gpx-dir). To speed up subsequent executions of the script, successfully loaded GPX tracks are cached in an intermediate format that allows for fast loading; use the option --clear-cache to delete these files. Tracks without time stamps and tracks recorded in the wrong year (option --year) are discarded. Tracks shorter than 1km are discarded, too If multiple tracks have been recorded within one hour, they are merged to a single track.

Filtering activities --from-strava FILE by activity_type

When using --from-strava FILE option, you may specify optional activity_type to filter only certain type(s) of activity to load. Note, activity_type filters activities only when loading from strava, and will not affect what already cached. That means if you change the value of activity_type you have to use --clear-cache to reload with the new filter. You can provide activity_type with a list or a string. All following examples are valid.

{
    "client_id": "YOUR STRAVA API CLIENT ID",
    "client_secret": "YOUR STRAVA API CLIENT SECRET",
    "refresh_token": "YOUR STRAVA REFRESH TOKEN",
    "activity_type": "Run"
}
{
    "client_id": "YOUR STRAVA API CLIENT ID",
    "client_secret": "YOUR STRAVA API CLIENT SECRET",
    "refresh_token": "YOUR STRAVA REFRESH TOKEN",
    "activity_type": ["Walk", "Hike"]
}
{
    "client_id": "YOUR STRAVA API CLIENT ID",
    "client_secret": "YOUR STRAVA API CLIENT SECRET",
    "refresh_token": "YOUR STRAVA REFRESH TOKEN"
}

Poster Types

Using the --type command line parameter, you can specify which type of poster to create:

Grid Poster (--type grid)

The Grid Poster layouts all tracks in a grid, starting with the earliest track in the upper left corner of the poster, continuing with the second earliest track to the left, and so on. Special tracks are drawn with the selected special color. Special distance tracks are drawn with the selected special color.

Example Grid Poster svg

Calendar Poster (--type calendar)

The Calendar Poster draws one square for each day, each row of squares corresponds to specific month. If a track was recorded of a day the corresponding square is colored with the track color or with the special color if the track is marked as special. A day's total track length in kilometers is printed below each square.

Example Calendar Poster svg

Circular Poster (--type circular)

The Circular Poster the year in a circle; each day corresponds to a circle segment. The length of each segment corresponds to the total track distance of that day.

Example Circular Poster svg

Heatmap Poster (--type heatmap)

The Heatmap Poster displays all tracks within one "map". The more often a location has been "visited" on a track, the more colorful the corresponding location is on the map. Special tracks are drawn with the special color.

Example Heatmap Poster svg

Github Poster (--type github)

The Github Poster displays all tracks like github profile. Special distance are drawn with the special color.

Example Github Poster svg

Selection a Language

create_poster uses gettext to provide localization to other languages. To select a different language than the default English, use the --language LANGUAGE option. We currently support

  • French (--language fr_FR)
  • German (--language de_DE)
  • Chinese (--language zh_CN)
  • Russian (--language ru_RU)
  • Finnish (--language fi_FI)

Setup

  1. Clone the repository: git clone https://github.com/flopp/GpxTrackPoster.git
  2. cd GpxTrackPoster
  3. Create virtualenv: virtualenv -p /usr/bin/python3 venv or python -m venv venv
  4. Activate virtualenv: source venv/bin/activate
  5. Install the package: pip install .
  6. Install development requirements (only if you want to contribute code!): pip install -r requirements-dev.txt
  7. Run create_poster (see above)
  8. Deactivate virtualenv: deactivate

Contributing

If you have found a bug or have a feature request, please create a new issue. I'm always happy improve the implementation!

Or even better: clone the repo, fix the bug/implement the feature yourself, and file a pull request. Contributions are always welcome!

Important: If you want to contribute via a pull request, make sure you run make lint and possibly make format and make update-readme before pushing code.

Translation

The translation is based on GNUs 'gettext'. For the translation of the month names to work, the language must be installed.

Use locale -a to check if the language is installed.

Use locale-gen ru_RU.UTF-8 to install another language and update the locale update-locale.

Add new translation

Example: msginit --input=gpxposter.pot --locale=de_DE --output=locale/de_DE/LC_MESSAGES/gpxposter.po

Update a translation

E.g. use Poedit or Localise Online Editor to edit the "po" files. Afterwards compile that files.

Create compiled translation file

msgfmt gpxposter.po -o gpxposter.mo

License

MIT Β© 2016-2023 Florian Pigorsch

More Repositories

1

go-staticmaps

A go (golang) library and command line tool to render static map images using OpenStreetMap tiles.
Go
312
star
2

py-staticmaps

A python module to create static map images with markers, geodesic lines, etc.
Python
107
star
3

go-findfont

A platform-agnostic go (golang) library to easily locate truetype font files in your system's user and system font directories
Go
106
star
4

FloppsMap

Online map with draggable markers, waypoint projection, geocaches, ...
JavaScript
27
star
5

activities

Your self-hosted activities overview (running, cycling, ...). Synced with Strava.
JavaScript
26
star
6

invisible-characters

A static website abou invisible Unicode characters
HTML
18
star
7

RandomWallpapers

Random geometric wallpaper generator
Python
14
star
8

unicode

A Flask-Based Web-App for Exploring Unicode
Python
11
star
9

DesktopJodel

A inofficial, Qt-based desktop client for the Jodel chat protocol
C++
11
star
10

alcazar-gen

SAT-based generator for Alcazar puzzles
C++
10
star
11

airports

Fullscreen satellite map randomly showing the world's airports
Python
8
star
12

QtAsciimage

QtAsciimage - Asciimage for Qt Applications
C++
7
star
13

fritz-switch-profiles

A (Python) script to remotely set device profiles of an AVM Fritz!Box
Python
7
star
14

dotter

Qt based viewer for GraphViz (.dot) files
C++
6
star
15

StravaExportToGPX

Convert the activites in a Strava export to GPX files
Python
6
star
16

map

TypeScript
5
star
17

exposure

A Leaflet-based heatmap showing exposure notification beacons
HTML
5
star
18

go-coordsparser

A library for parsing (geographic) coordinates in go (golang)
Go
4
star
19

QtDateTimeEditor

A user and keyboard friendly alternative to Qt's QDateTimeEdit
C++
4
star
20

pyqt5-cpp-widgets

PyQt5, Python3 and Custom C++ Widgets
Python
3
star
21

aoc2021

My solutions for Advent of Code 2021.
Go
2
star
22

camelsplit

Camel case aware word splitting.
Python
2
star
23

coordinates-toolbox

A single page web-app providing several (geographic) coordinate calculations
JavaScript
2
star
24

gpx-map

Online Map displaying GPX tracks and makers (client side only!)
JavaScript
2
star
25

RunalyzeVagrant

Vagrant configuration for a Runalyze development environment
Shell
2
star
26

mantis-enhancer-user-script

User script enhancing Mantis BT
JavaScript
1
star
27

gol-sat

A SAT-based forward/backwards solver for Conway's "Game of Life".
C++
1
star
28

tracks

A static map of your FIT/GPX tracks
Python
1
star
29

overpass-poi-map

Leaflet map with POIs from the Overpass API
JavaScript
1
star
30

git-repo-backup

Backup a git repository using rsync
Shell
1
star
31

aoc2022

Go solutions for Advent of Code 2022 (aoc2022)
Go
1
star
32

aoc2020

My solutions for Advent of Code 2020
Python
1
star
33

aoc2016

My solutions for 'Advent of Code' 2016
C++
1
star
34

ocdl.py

Python script for downloading opencaching.de's "saved queries"
Python
1
star
35

parkrun-milestones

Determine milestone candidates for a parkrun event
Go
1
star
36

whataweek-mastodon

Go
1
star
37

go-getfile

Go module to download files
Go
1
star