Skip to main content

gpx-to-map

Convert a folder of GPX tracks into an interactive HTML map (lonboard / deck.gl) or a static PNG image (matplotlib + contextily) with a single command.

example output

Installation

pip install gpx-to-map

Usage

gpx-to-map <gpx-folder> <output-file> [OPTIONS]
Argument Description
gpx-folder Directory containing .gpx files
output-file Destination path — .html for interactive, .png for static

Options

Option Default Description
--style / -s dark Background map style: dark, light, voyager
--color / -c red Track color — any matplotlib name, hex (#1f77b4), or CSS color
--highlight-latest / --no-highlight-latest disabled Highlight the most recent track with a contrasting accent color. Recency is determined by the first trackpoint timestamp in each GPX file, falling back to file modification time
--geojson-folder (discard) Keep intermediate GeoJSON files in this folder (created if absent)
--dpi 200 Resolution for PNG output in dots per inch; ignored for HTML

Examples

# Interactive map with default dark style
gpx-to-map ./rides output.html

# Light basemap, steelblue tracks, highlight the latest ride
gpx-to-map ./rides output.html --style light --color steelblue

# Export a static PNG instead
gpx-to-map ./rides output.png --style voyager --color "#e07b39"

# Don't highlight the latest track
gpx-to-map ./rides output.html --no-highlight-latest

How it works

  1. Every .gpx file in the folder is converted to GeoJSON via geojson-transformer.
  2. All tracks are loaded into an in-memory DuckDB database using the spatial extension.
  3. HTML output — renders an interactive lonboard / deck.gl PathLayer map and saves it as a self-contained HTML file.
  4. PNG output — plots the tracks with matplotlib and overlays map tiles via contextily, then saves a high-resolution raster image.

The latest GPX file is always loaded into a separate layer so it can be highlighted. "Latest" is determined by the timestamp of the first trackpoint (<trkpt><time>) recorded in the file; files without trackpoint timestamps (e.g. manually-planned routes) fall back to their filesystem modification time.

Python API

create_map can be called directly from Python without the CLI:

from pathlib import Path
from gpx_to_map.core import create_map

create_map(
    gpx_folder=Path("./rides"),
    output_file=Path("output.html"),   # or "output.png" for a static image
    style="dark",                       # "dark" | "light" | "voyager"
    color="steelblue",
    highlight_latest=True,
    geojson_folder=Path("./geojson"),  # optional: keep intermediate GeoJSON files
)

All parameters correspond directly to the CLI options. style accepts the same string values as --style.

Development

git clone https://codeberg.org/marioangst/winti-zh-gpx
cd gpx-to-map
uv sync
uv run gpx-to-map --help

Download files

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

Source Distribution

gpx_to_map-0.1.0.tar.gz (122.9 kB view details)

Uploaded Source

Built Distribution

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

gpx_to_map-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gpx_to_map-0.1.0.tar.gz
  • Upload date:
  • Size: 122.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"21.3","id":"virginia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gpx_to_map-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9d24aba6ab4cc627be50c643eea03f3a05c7d397ad21cd485e60670baa6db4d5
MD5 7d06e23f29e1b8a3ae1daab39e2f3628
BLAKE2b-256 6f9fa137e9a3becf0468edc8bca33b27d258a70a5dc0cf66aa7a5070996fced4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gpx_to_map-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"21.3","id":"virginia","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for gpx_to_map-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b58275906108d77d201fd0296fa93379eb5f180662944cf23ff7c2283c97ce6d
MD5 2ec97441ef94a00cc43ec184bed6a8b9
BLAKE2b-256 1346b322978f23eb6f2ff4c45bdfed69dc3d2420254cb711d51f331a27dc74ea

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.0

2 files

0.1.1

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page