Vendredi 23 novembre 2018 (Modifié le Vendredi 23 novembre 2018)

2017-05-09-Gpx-Python-Script

GPX

Exploring GPX files (python)

Sur archlinux/manjaro
python –version –> Python 3.6.1

Installer un package simplement avec Python : pip

yaourt -S python-pip

Python Data Analysis Library , installation module pandas GPX file parser and GPS track manipulation library,http://www.trackprofiler.com/gpxpy/index.html

sudo pip install pandas
sudo pip install gpxpy

Vérifier paquet installé

pip freeze |grep [pandas,gpxpy]
    pandas==0.20.1

Script de test sur fichier gpx

import gpxpy.parser as parser

gpx_file = open( 'Piste_2017-03-19 112523.gpx', 'r' )

gpx_parser = parser.GPXParser( gpx_file )
gpx_parser.parse()

gpx_file.close()

gpx = gpx_parser.get_gpx()

for track in gpx.tracks:
    for segment in track.segments:
        for point in segment.points:
            print 'Point at ({0},{1}) -> {2}'.format( point.latitude, point.longitude, point.elevation )

for waypoint in gpx.waypoints:
    print 'waypoint {0} -> ({1},{2})'.format( waypoint.name, waypoint.latitude, waypoint.longitude )

for route in gpx.routes:
    print 'Route:'
    for point in route:
        print 'Point at ({0},{1}) -> {2}'.format( point.latitude, point.longitude, point.elevation )

# There are more utility methods and functions...

# You can manipulate/add/remove tracks, segments, points, waypoints and routes and
# get the GPX XML file from the resulting object:

print 'GPX:', gpx.to_xml()