# GPX Simplifier

Paste a GPX track and reduce its point count with Douglas-Peucker tolerance in meters while preserving route shape, endpoints, elevation and times.

## Run it

- **CLI:** `gizza tool gpx-simplify '<gpx><trk><trkseg>
<trkpt lat="37.7749" lon="-122.4194"><ele>10</ele><time>2026-08-06T10:00:00Z</time></trkpt>
<trkpt lat="37.7750" lon="-122.4193"></trkpt>
<trkpt lat="37.7760" lon="-122.4180"></trkpt>
</trkseg></trk></gpx>'`
- **Web:** https://gizza.ai/tools/gpx-simplify/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/gpx-simplify/tool.json

## Inputs

- `input` — GPX track _(field)_
- `tolerance_meters` — Tolerance (meters) _(field)_
- `keep_every` — Also keep every Nth source point (0 = off) _(field)_
- `decimals` — Coordinate decimals _(field)_
- `output` — Output _(field)_

## Output

- Simplified GPX (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `input` — GPX track
- `tolerance_meters` — Tolerance (meters)
- `keep_every` — Also keep every Nth source point (0 = off)
- `decimals` — Coordinate decimals
- `output` — Output

Example: `https://gizza.ai/tools/gpx-simplify/?input=%3Cgpx%3E%3Ctrk%3E%3Ctrkseg%3E%0A%3Ctrkpt%20lat%3D%2237.7749%22%20lon%3D%22-122.4194%22%3E%3Cele%3E10%3C%2Fele%3E%3Ctime%3E2026-08-06T10%3A00%3A00Z%3C%2Ftime%3E%3C%2Ftrkpt%3E%0A%3Ctrkpt%20lat%3D%2237.7750%22%20lon%3D%22-122.4193%22%3E%3C%2Ftrkpt%3E%0A%3Ctrkpt%20lat%3D%2237.7760%22%20lon%3D%22-122.4180%22%3E%3C%2Ftrkpt%3E%0A%3C%2Ftrkseg%3E%3C%2Ftrk%3E%3C%2Fgpx%3E&tolerance_meters=10&keep_every=0&decimals=6&output=gpx`

---

## About this tool

Large GPX tracks slow down map apps, syncing, and route sharing. This tool reduces the number of `<trkpt>` points with the Douglas-Peucker algorithm: endpoints are always kept, then the algorithm keeps only the intermediate points needed to stay within your chosen tolerance in meters.

The result is a clean GPX 1.1 document. Elevation and time values on kept points are preserved, and the summary output lets you preview how many points would be removed before exporting.

### Worked example

Input:

```
<gpx><trk><trkseg>
<trkpt lat="0" lon="0"><ele>1</ele><time>2026-08-06T00:00:00Z</time></trkpt>
<trkpt lat="0" lon="0.0001"></trkpt>
<trkpt lat="0.001" lon="0.001"></trkpt>
<trkpt lat="0" lon="0.002"></trkpt>
</trkseg></trk></gpx>
```

With a 50 m tolerance the jitter point near the start is dropped while the bend and both endpoints remain:

```
<?xml version="1.0" encoding="UTF-8"?>
<gpx version="1.1" creator="gpx-simplify" xmlns="http://www.topografix.com/GPX/1/1">
  <trk>
    <trkseg>
      <trkpt lat="0" lon="0">
        <ele>1</ele>
        <time>2026-08-06T00:00:00Z</time>
      </trkpt>
      <trkpt lat="0.001" lon="0.001"></trkpt>
      <trkpt lat="0" lon="0.002"></trkpt>
    </trkseg>
  </trk>
</gpx>
```

Switching the output to **Summary only** previews the same run without exporting XML:

```
GPX simplify: 4 → 3 points (25.0% removed)
Tolerance: 50 m
Distance before: 318.0 m
Distance after: 314.5 m
```

Raising the tolerance to 200 m removes the bend as well (4 → 2 points), because the bend sits only about 111 m off the straight line between the endpoints.

### Limits and edge cases

- The parser focuses on GPX track points (`<trkpt lat="…" lon="…">`). Routes (`<rtept>`) and waypoints (`<wpt>`) are not simplified.
- All `<trkpt>` points in the document are treated as one continuous path and written back as a single `<trk>`/`<trkseg>`. Multi-track or multi-segment files are flattened, so split them first if segment boundaries matter.
- The input must contain at least two track points; a file with one point (or none) returns an error instead of an empty track.
- Elevation (`<ele>`) and timestamp (`<time>`) are preserved for points that remain; other nested extension metadata is not copied.
- Distances use a local spherical/equirectangular approximation, which is appropriate for normal GPS tracks but not survey-grade geodesy.
- A tolerance of 0 keeps every bend; higher tolerances shrink the file more aggressively.

<details>
<summary>What tolerance should I use?</summary>

For running and hiking tracks, 5–20 meters usually removes GPS jitter while preserving shape. For driving or country-scale tracks, 50–200 meters may be fine. Use the summary output to preview the reduction before exporting GPX.

</details>

<details>
<summary>Does it keep the first and last point?</summary>

Yes. Douglas-Peucker always keeps segment endpoints, and this tool also lets you keep every Nth original point as an extra safety sample.

</details>

<details>
<summary>Will this preserve heart-rate or extension data?</summary>

No. The simplified GPX keeps coordinates plus the common `ele` and `time` children for retained points. Vendor extensions are intentionally dropped in the clean output.

</details>

<details>
<summary>Why did my distance change slightly?</summary>

Removing points straightens tiny wiggles, so the simplified path length can be a little shorter. Lower the tolerance if you need more detail.

</details>

<details>
<summary>What does "keep every Nth source point" do?</summary>

It is an extra safety sample on top of Douglas-Peucker: with a value of 10, every 10th original point is retained even if the tolerance would have dropped it. That bounds how far apart kept points can drift on long straight stretches — useful when a downstream app expects a roughly regular sampling rate. Leave it at 0 to let the tolerance decide alone.

</details>

<details>
<summary>How do the coordinate decimals affect file size?</summary>

Each decimal place is one more character per coordinate. Six decimals is about 11 cm of precision at the equator; five is about 1.1 m, which is already finer than consumer GPS accuracy. Dropping from six to five decimals shrinks a large track noticeably with no visible change on a map. Trailing zeros are trimmed automatically.

</details>

<details>
<summary>My file has several tracks or segments — what happens?</summary>

Every `<trkpt>` in the document is read in order as one path and written back as a single track with one segment. If the segment breaks are meaningful (for example a paused recording), split the file before simplifying and run each part separately.

</details>

## Related tools

- [Absolute value, sign, or negation for a whole column](https://gizza.ai/tools/absolute-value-transformer/): Paste a column of numbers and apply absolute value, sign extraction (-1/0/1), sign flipping, or force-negative to every value at once, with rounding and an audit table.
- [Adjacency Matrix Converter](https://gizza.ai/tools/adjacency-matrix-converter/): Convert a graph between edge list, adjacency matrix, and incidence matrix — directed or undirected, weighted or not. Free, private, runs in your browser.
- [Amazon Order Analyzer](https://gizza.ai/tools/amazon-order-analyzer/): Paste an Amazon order-history CSV export to summarize total spend by month, top items, and category breakdowns. Browser-only, private, with Markdown or JSON output.
- [ARFF Converter](https://gizza.ai/tools/arff-converter/): Convert Weka ARFF datasets to CSV and CSV tables back to ARFF locally — nominal attributes, numeric types, dates, sparse rows, missing values, and type rows.
- [Avro to JSON Converter](https://gizza.ai/tools/avro-to-json/): Decode Apache Avro Object Container Files (.avro / OCF) to JSON, NDJSON, or the embedded schema — no .avsc needed, free and private in your browser.
