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.
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
- Every
.gpxfile in the folder is converted to GeoJSON viageojson-transformer. - All tracks are loaded into an in-memory DuckDB database using the
spatialextension. - HTML output — renders an interactive lonboard / deck.gl
PathLayermap and saves it as a self-contained HTML file. - 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/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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gpx_to_map-0.1.1.tar.gz.
File metadata
- Download URL: gpx_to_map-0.1.1.tar.gz
- Upload date:
- Size: 122.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8b2aefa28b86ac98f3fd7ccefda313dfe89ef6b312a2f5c6f432385354ddb66
|
|
| MD5 |
7d5566ca443e90436e57e09de2d83a12
|
|
| BLAKE2b-256 |
9f63e986bf98a06607d6324b22e95e64af88665b88701efc45ece829d7e3f1a8
|
File details
Details for the file gpx_to_map-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gpx_to_map-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Linux Mint","version":"22.3","id":"zena","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35947c9692cfc97bca5a1074bc47473441927adbb4048444ef6a5138704849f4
|
|
| MD5 |
f021969b79a5e295a88c830da61f05ef
|
|
| BLAKE2b-256 |
4ccafb9c81c1f734c78fc486ea6cd3f6159d25686cf6c8edb43b871ccca4a7f8
|