Skip to main content

gpxslicer

gpxslicer slices GPX tracks at a given interval or at a list of provided cut points.

Installation

The best way to install gpxslicer is via pip: pip install gpxslicer. You can alternatively install it from the source code: python setup.py install.

Usage

Command line

gpxslicer is primarily intended to be used as a command line tool (with support for redirection and piping data in/out).

gpxslicer -i in.gpx -d 5000 > out.gpx would, for example, take the tracks in infile.gpx, split them at every five kilometers, then pipe the results into out.gpx.

Full description of command line options:

flag command description
-h --help Show the help.
-i --input Specify the input GPX file with tracks to be sliced. If not given, input is read from stdin.
-o --output Specify the output GPX file. If not given, input is written to stdout.
-d --distance Slice tracks at every DISTANCE meters.
-e --external Slice tracks at waypoints found in EXTERNAL file.
-w --waypoints Slice tracks at waypoints found in INPUT.
--no-tracks Do not store sliced tracks in the output. Useful when slicing using -d and only the cut points are of interest.
--no-waypoints Do not store cut points in the output. Useful when slicing using -e or -w so the points are already (approximately) known.
-q --quietly Do not display status messages (that are normally sent to stderr).

Slicing at intervals

When using -d, gpxslicer goes through each track and track segment separately (always restarting the distance counter when a new track or track segment starts in the input file).

Cut points are not interpolated but chosen from available points on the track. Therefore, if there are very few points in the track or the chosen interval is small, there can be a significant variation in the actual length of the cut segments. There should be no major problems with sufficiently many track points and large slice distances.

Slicing at waypoints

When using -e or -w, gpxslicer uses the get_nearest_location method from the GPX class of gpxpy. This finds the point of the tracks stored in the input file that is closest to the given slice point, and then splits the track there. Finally, it duplicates this point into the new track to prevent a gap. When the slice points are very far from the track, there can be unexpected or insensible results.

Note that all waypoints in the gpx file will be used, so any unnecessary waypoints should be removed beforehand.

Python package

The two main functions, slice_gpx_at_points() and slice_gpx_at_interval() can be accessed by

from gpxslicer import slicer
slicer.slice_gpx_at_interval(gpx_data, interval)
slicer.slice_gpx_at_points(gpx_data)

Detailed documentation of these functions can be found in the code.

More info

Read more about this package, including the motivation to write it on my blog.

Metadata

Release files for gpxslicer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gpxslicer 0.1.0
File Size Uploaded
gpxslicer-0.1.0.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gpxslicer 0.1.0
File Interpreter ABI Platform
gpxslicer-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.8 kB

Release files / gpxslicer-0.1.0.tar.gz

Download URL gpxslicer-0.1.0.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
343004e3a340579f56a73ebd6b49c3b3d76ff8caee6b37e2e10f583186f9b6ef
BLAKE2b-256 checksum
How to use checksums
c3bee3d715349262d3d2c052c9b378cee1e163b39d40a66e6f6d73eb4ef1bec5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.1

Release files / gpxslicer-0.1.0-py3-none-any.whl

Download URL gpxslicer-0.1.0-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
80a51ba6d8ab2cfd8124819c92491a5eaf2b186339a4d5cf0955c33f8dd4d345
BLAKE2b-256 checksum
How to use checksums
970f96af418731b1c1c744e973023e5d09ddb6349bf6e1b7ecfcb8915b93ff29
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release 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