Skip to main content

Visualise & animate GPX race tracks.

Project description

gpx-player

GPX Race Visualizer

GPX Race Visualizer is a Python script to visualize the progression of multiple GPS tracks (e.g., from a race) on a 2D map. It takes as input one or more GPX files and creates an animation showing the movement of each track over time. This is a simple, open-source alternative to features like Strava's Flyby, which require an account and can have privacy issues.

Modes

The player supports two modes:

1. "Video" mode

Produce an MP4 or a GIF file showing how the situation developed. For sailing races, it also calculates the distance covered after the 'start' signal and the current speed.

Example:

Example output

2. Map mode

Displays the track on OpenSeaMap. You can see the full tracks with colour-coded speeds, and you can 'play' the tracks and see the markers move around the map.

Example:

Since GitHub Markdown doesn't allow embedding HTML, you can see an interactive example here.

Screenshot: OPS Example

Installation

Clone the repository and install the required dependencies with pip:

git clone https://github.com/kirienko/gpx-player.git
cd gpx-player
pip install -r requirements.txt

Usage

To run the script producing mp4, pass one or more GPX file paths as command-line arguments:

python main.py example-data/track1.gpx example-data/track2.gpx

To get a sea map, run the openseamap.py:

python openseamap.py --title 'Gin Sul Regatta 2024' --names Alex Yury Richard \
     --files example-data/osm-demo-Alex.gpx example-data/osm-demo-Richard.gpx \
             example-data/osm-demo-Yury.gpx

A more sophisticated example, that produced a video above:

python main.py example-data/track1.gpx example-data/track2.gpx example-data/track3.gpx \
       --start 2023-07-01T10:53:00+0000 \
       --names "Mr. Pommeroy" "Miss Sophie" "Sir Toby²" \
       --title "Elbe-Damm Regatta (01.07.2023), Race 1" \
       --race_start 2023-07-01T10:58:00+0000 --marks example-data/marks.txt -g

Additional parameters:

  • --title or -t: The title of the video
  • --start or -s: start time in the format 2023-06-30T12:53:00+0200, all points before that will not be plotted
  • --end or -e: end time in the format 2023-06-30T13:53:00+0200, all points after that will not be plotted
  • --names or -n: names of the participants (otherwise the file names will be used in the legend)
  • --race_start, -r: Race start time in the format YYYY-MM-DDTHH:MM:SS%z, e.g. 2023-07-01T12:29:00+0200
  • --names or -n: Names of the participants
  • --marksor-m: The file with the static marks to put onto the map. One pair of coordinates per line, see below.
  • --gif or -g: Save as GIF moving picture instead of MP4
  • --timezone or -tz: Local timezone to use for processing timestamps, e.g. America/Los_Angeles, see here (default: Europe/Berlin).

Marks

The script also supports visualizing predefined marks on the map, which can be useful for events like sailing regattas. The marks are defined as a list of (latitude, longitude) tuples in a separate text file and can be added to the script as follows:

53.542484632728, 9.801163896918299
53.542997846049374, 9.80611324310303
53.54823800356785, 9.812614917755129
53.54921647691311, 9.807373881340029
53.54508251196638, 9.80433225631714

Getting GPX Files

GPX files can be obtained from several GPS-tracking services:

  • Strava: Go to the activity page and click on the wrench icon. Then select "Export GPX".
  • Garmin Connect: Open the activity, go to the gear icon and select "Export to GPX".
  • Endomondo: From the workout page, click the three-dot menu icon and select "Export". Then choose "GPX".

GPX Validation

For the gpx-player to work properly, it needs the correct GPX files. You can verify that you are inputting the correct file by using the special validator included in this package.

The validator.py script is a command-line utility and module for validating GPX files. It checks for XML schema conformance and timestamp consistency, supporting both strict and lenient modes. Errors are raised as GPXValidationError which can be caught in Python code. To run as a CLI tool, use:

python validator.py path/to/yourfile.gpx --strict

The --strict parameter is optional. In most cases you do not need it, because files that strictly correspond to the GPX schema are rare. For example, almost all modern files contain coordinates, elevations and time stamps with more decimal places than originally planned.

Also, to better understand your GPX file, you can use the gpxinfo console command that comes with gpxpy. If you are already using the player, you have it:

$ gpxinfo example-data/osm_track1.gpx 
File: example-data/osm_track1.gpx
    Waypoints: 0
    Routes: 0
    Length 2D: 9.621km
    Length 3D: 9.648km
    Moving time: 01:05:22
    Stopped time: n/a
    Max speed: 3.12m/s = 11.22km/h
    Avg speed: 2.46m/s = 8.85km/h
    Total uphill: 97.20m
    Total downhill: 98.40m
    Started: 2024-07-24 15:59:05+00:00
    Ended: 2024-07-24 17:04:27+00:00
    Points: 776
    Avg distance between points: 12.40m

Support

Now you can buy me a coffee to encourage further development!

"Buy Me A Coffee"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpx_player-0.1.0.tar.gz (22.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gpx_player-0.1.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file gpx_player-0.1.0.tar.gz.

File metadata

  • Download URL: gpx_player-0.1.0.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gpx_player-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fd384b145a3e8388953a1fa9b1e8cc566564bf9dd970e51008d29f072f31fd4c
MD5 b9b6f5693cc7f1322ebd6d53d740ec1f
BLAKE2b-256 6c59ca0e42e1cc79096724bc1c557e7503dfd15450b5cf1d7174544b22345f4c

See more details on using hashes here.

Provenance

The following attestation bundles were made for gpx_player-0.1.0.tar.gz:

Publisher: publish.yml on kirienko/gpx-player

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gpx_player-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gpx_player-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for gpx_player-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d3ca4f004a7a97b61a7158c3497ff5b4190e72d879e50ea3e82073c4ac9b4fbc
MD5 5fc50e7a7fe4cd65463bfe1a2b1dc666
BLAKE2b-256 152d6833b14c8a7837f66f2e7b24d2fabe8cc333535d11dbe8c93c1f59ba415a

See more details on using hashes here.

Provenance

The following attestation bundles were made for gpx_player-0.1.0-py3-none-any.whl:

Publisher: publish.yml on kirienko/gpx-player

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page