Process GPX files
A script that takes a gpx file, saving a new one with a standard suffix '_pp' (that can be changed with the --suffix option) after performing the following adjustments to it:
-
Each segment in the original file becomes a track in the new file i.e. tracks and tracksegments become de facto the same thing.
-
Each new track has the name of the timestamp of the first trackpoint.
-
Tracksegments/Tracks with less than the default number of 3 trackpoints are deleted from the processed file. This can be changed with the --minpoints option.
-
Empty track segments in the original file are deleted
-
Duplicate segments (based on the first timestamp occuring more than once) are deleted.
-
Track segments are sorted by time.
-
Trackpoints with a missing 'ele' (elevation) tag get added with a value of 0.
-
The --crop option drops the first and last point from every trackseg (this improves cleaning as these points are often spurious).
There is one argument: the path to the gpx file to process
Options:
- --suffix : change the file suffix
- --destination : specify a destination folder for the processed file
- --crop: turn on cropping of first and last trackpoints
- --minpoints : set the maximum number of points a track must have
- --quiet: don't print any information to STDOUT
See --help for details
I call it preprocesssing because I have several processes to go through before the file is accepted into our spatialite reference database. So this is a preliminary step before running [gpx2spatialite] (https://github.com/ptrv/gpx2spatialite)