gpx-rs
A Rust library and CLI for reading, validating, editing, and converting GPX files (GPX 1.1).
Installation
Or build locally:
# binary: target/release/gpx
CLI
The command-line tool is named gpx.
validate
Validate a GPX file against the GPX 1.1 schema.
| Flag | Description |
|---|---|
--strict |
Treat warnings as failures (non-zero exit code) |
--json |
Output the validation report as JSON |
Examples
On success, prints a summary with creator, waypoint/route/track counts, and any schema issues. Exit code 0 when valid (and no warnings if --strict); 1 otherwise.
info
Show information and statistics about a GPX file (distance, duration, elevation, bounds).
| Flag | Description |
|---|---|
--json |
Output statistics as JSON |
--strict |
Validate against the GPX 1.1 schema before gathering info |
Examples
edit
Apply one or more transformations to a GPX file and write the result.
| Flag | Description |
|---|---|
-o, --output-file |
Output file path (required) |
--strict |
Validate input against GPX 1.1 before editing |
Crop (bounding box filter; omit a bound to leave that side open):
| Flag | Description |
|---|---|
--min-lat <DEG> |
Minimum latitude |
--max-lat <DEG> |
Maximum latitude |
--min-lon <DEG> |
Minimum longitude |
--max-lon <DEG> |
Maximum longitude |
Time trim (ISO 8601 / RFC 3339 datetimes):
| Flag | Description |
|---|---|
--start <DATETIME> |
Drop points before this time |
--end <DATETIME> |
Drop points after this time |
Split (break tracks/routes at gaps):
| Flag | Description |
|---|---|
--split-time-gap <SECS> |
Split when consecutive points exceed this time gap |
--split-distance-gap <METERS> |
Split when consecutive points exceed this distance |
Geometry
| Flag | Description |
|---|---|
--simplify <TOLERANCE> |
Douglas–Peucker simplification tolerance (meters) |
--smooth <WINDOW> |
Moving-average smoothing window size (point count) |
--shift-time <SECS> |
Shift all timestamps by this many seconds |
--reverse |
Reverse all routes and tracks |
--reverse-routes |
Reverse routes only |
--reverse-tracks |
Reverse tracks only |
Metadata stripping
| Flag | Description |
|---|---|
--strip-all-metadata |
Remove all metadata fields |
--strip-name |
Remove name fields |
--strip-desc |
Remove description fields |
--strip-author |
Remove author |
--strip-copyright |
Remove copyright |
--strip-time |
Remove timestamps |
--strip-keywords |
Remove keywords |
--strip-links |
Remove links |
--strip-extensions |
Remove all extension elements |
Precision
| Flag | Description |
|---|---|
--precision <DIGITS> |
Decimal places for latitude/longitude |
--elevation-precision <DIGITS> |
Decimal places for elevation |
Examples
# Reverse track point order
# Crop to a bounding box and simplify
# Trim to a time range and strip extensions
# Reduce coordinate precision
Multiple flags can be combined; transformations are applied in a fixed order (crop → trim → split → simplify → smooth → shift time → reverse → strip metadata → strip extensions → reduce precision).
merge
Merge multiple GPX files into one.
| Flag | Description |
|---|---|
-o, --output-file |
Output file path (required) |
--strict |
Validate each input against GPX 1.1 before merging |
Examples
Waypoints, routes, and tracks from all inputs are concatenated into a single document.
convert
Convert between GPX, GeoJSON, and KML. Format is detected from the file extension (.gpx, .geojson, .json, .kml).
| Flag | Description |
|---|---|
-o, --output-file |
Output file path (required) |
--strict |
Validate GPX input against GPX 1.1 before converting |
Examples
Library
The library crate is published as gpx_rs. Add it as a dependency:
[]
= { = "path/to/gpx-rs" }
use ;
let gpx = parse_file?;
let path = from;
println!;
println!;
See AGENTS.md for API details, statistics semantics, and extension support.
Development
Run the CLI during development: