Skip to main content

Slice up gpx tracks based on distance from the start or custom waypoints

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gpxslicer-0.1.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

gpxslicer-0.1.0-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file gpxslicer-0.1.0.tar.gz.

File metadata

  • Download URL: gpxslicer-0.1.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for gpxslicer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 343004e3a340579f56a73ebd6b49c3b3d76ff8caee6b37e2e10f583186f9b6ef
MD5 804a89f0cf3f654e70ad5d60d7303e43
BLAKE2b-256 c3bee3d715349262d3d2c052c9b378cee1e163b39d40a66e6f6d73eb4ef1bec5

See more details on using hashes here.

File details

Details for the file gpxslicer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: gpxslicer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for gpxslicer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 80a51ba6d8ab2cfd8124819c92491a5eaf2b186339a4d5cf0955c33f8dd4d345
MD5 9c84fc6502ea51531bc40dc6e63cba28
BLAKE2b-256 970f96af418731b1c1c744e973023e5d09ddb6349bf6e1b7ecfcb8915b93ff29

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page