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
--show-names / --no-show-names off Show place-name labels on dark/light HTML basemaps (hidden by default; voyager always shows them); ignored for PNG
--detail 1 Extra basemap zoom levels for PNG sharpness (0 = library default, higher = sharper but slower); ignored for HTML

Examples

Let's assume you have a folder of gpx files ./rides.

# 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 over an OpenFreeMap vector basemap (MapLibre GL) and saves it as a self-contained HTML file. On the dark and light styles the basemap's place-name labels are stripped by default (pass --show-names to keep them).
  4. PNG output — plots the tracks with matplotlib and overlays no-key Esri raster tiles via contextily (fetched one zoom level deeper than the default for sharpness — tunable with --detail), then saves a high-resolution raster image. The dark style darkens the tiles toward black so the tracks stand out.

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.

Basemaps & attribution

HTML maps use free, no-API-key vector basemaps from OpenFreeMap. OpenFreeMap is run as a public good with no usage limits — if you find it useful, please support it via GitHub Sponsors.

PNG maps use no-key raster tiles from Esri. Keep the on-map attribution visible in anything you publish.

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/gpx-to-map
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.2.0.tar.gz (126.7 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.2.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gpx_to_map-0.2.0.tar.gz
  • Upload date:
  • Size: 126.7 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.2.0.tar.gz
Algorithm Hash digest
SHA256 a14bf0846f2829f4f6f8f8ba375a1d510880de0459a2138eee8a5afbc1634a21
MD5 9ad59d8872c9a91f1ed5c80ceb2d2699
BLAKE2b-256 737ddbcacbc1e8717c659e3d345b40dc8d517e0219a1b05f9988490f4f21d9bf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gpx_to_map-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1662fc83e3bd736445dafb375163bb3fe01f367ffcc9894b39ac10166edeebcb
MD5 319454a57eceecc52f303b104333eb96
BLAKE2b-256 06fa8301dc0c682f96290a564e44c3df99e8548e710a002a30f462afa7564cc7

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 files

0.1.1

2 files

0.1.0

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