Giter Club home page Giter Club logo

gpx-tools's Introduction

gpx-tools

Some Python scripts to deal with GPX files

gpx-split

Usage: gpx-split <filename>

This script splits out tracks from a GPX file into different files, one file per date. It removes all non-track items (routes, waypoints, extensions), so only tracks are retained. It does not modify the original file, but if a file for a given date already exists, it merges the result into the existing file.

For example, consider a GPX file, that contains tracks from several dates (the date for a track is taken from the <time> tag from the first <trkpt> in the track), let's say 2, 3 and 4 January 2014. Running 'gpx-split' on the file will give you the following new files:

  • 2014-01-02-000.gpx
  • 2014-01-03-000.gpx
  • 2014-01-04-000.gpx

If you have a second GPX file, that contains tracks for 4 and 5 January, the following happens:

  • tracks from January 4th are merged into 2014-01-04-000.gpx
  • a new file named '2014-01-05-000.gpx' is created

If some of the tracks in the second file have the same names as tracks from the first file, the number of track points in the track is examined, and the higest number wins. So if the track from the second file has more points than the existing track, it will completely replace the existing track from the first file, otherwise it is discarded. No effort is made to merge identically named tracks together. In other words: if identically named tracks differ in number of points, the shorter one is expected to be a subset of the longer one.

This is convenient for some Garmin GPS devices (most notably the Zumo), that create weird track archives.

gpx-merge

Usage: gpx-merge <file1> <file2>

This script merges tracks from <file2> into <file1> and optionally deletes <file2>. If <file1> contains non-track items (routes, waypoints), they are left untouched, but the script does not regard non-track items from <file2>.

It first analyzes <file1> and then scans <file2> for tracks. If a certain track name from <file2> does not occur in <file1>, the track is simply appended to <file1>. If the name does already occur, the number of track points in the track is examined, and the higest number wins. So if the track from <file2> has more points than the track from <file1>, it will completely replace the existing track, and otherwise it is discarded.

The script is interactive, which means that if the merge operation leads to changes in <file1>, the user is asked whether <file1> may be overwritten and <file2> removed. If <file1> is not to be modified, the user is still offered the option to delete <file2>.

gpxtools.py

The scripts described above are merely wrappers around functions in the gpxtools.py module. All the real functionality is in the module.

Dependencies

The scripts are developed and tested on Python 2.7. Other versions are untested. All XML operations are done with lxml.etree. There are no external dependencies. Development and testing takes place on Linux, but superficial testing indicates, that the scripts also work with Python 2.7 on Windows.

License

The gpx-tools are copyright (c) 2014 Martijn Grendelman and licensed under the Apache License, version 2.0. A copy of the license can be found in the 'LICENSE' file and on the web.

The included copy of iso8601.py, a simple ISO 8601 date parsing module, is copyright (c) 2007-2014 Michael Twomey and downloaded from here. It is released under a permissive license, that can be found in the file iso8601.LICENSE.

gpx-tools's People

Contributors

tinuzz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.