[Python] Read a GPX to identify when and for how long it was paused

Discussão em 'Python' iniciado por Stack, Agosto 25, 2025.

  1. Stack

    Stack Membro Participativo

    When doing long distance bike rides or runs, it would be useful to know when and how long I had stopped. None of the usual sports tracking websites or GPX tools seem to provide this facility, so it seems like an interesting coding challenge to extract this information.

    I am familiar with python and can see that other GPX questions have made good use of the gpxpy library. How could I extend this to show times when the track has stopped?

    As an extra it would be good to lookup the address of where I stopped.

    # Read a GPX and find the significant time gaps
    # Show the date & time (when stopped), duration and location (lat,lon can be pasted into Google maps' search).

    import gpxpy.gpx
    import datetime
    import sys

    # Get GPX file name and option from arguments
    file = '../original/2019-07 Dunwich_Dynamo.gpx'

    # Get GPX file and parse it
    gpx_file = open(file, 'r')
    gpx = gpxpy.parse(gpx_file)
    point_data = gpx.get_points_data()

    i = 0
    for track in gpx.tracks:
    for segment in track.segments:
    for point in segment.points:
    i += 1
    print('Time {0} at ({1},{2})'.format(point.time, point.latitude, point.longitude))
    if i > 10:
    break

    Continue reading...

Compartilhe esta Página