def get_lat_lon_time_from_gpx(gpx_file, local_time=True):
    '''
    Read location and time stamps from a track in a GPX file.

    Returns a list of tuples (time, lat, lon).

    GPX stores time in UTC, by default we assume your camera used the local time
    and convert accordingly.
    '''
    with open(gpx_file, 'r') as f:
        gpx = gpxpy.parse(f)

    points = []
    if len(gpx.tracks) > 0:
        for track in gpx.tracks:
            for segment in track.segments:
                for point in segment.points:
                    t = utc_to_localtime(point.time) if local_time else point.time
                    points.append((t, point.latitude, point.longitude, point.elevation))
    if len(gpx.waypoints) > 0:
        for point in gpx.waypoints:
            t = utc_to_localtime(point.time) if local_time else point.time
            points.append((t, point.latitude, point.longitude, point.elevation))

    # sort by time just in case
    points.sort()

    return points
def get_lat_lon_time_from_gpx ( gpx_file , local_time = True ) : with open ( gpx_file , 'r' ) as f : gpx = gpxpy . parse ( f ) points = [ ] if len ( gpx . tracks ) > 0 : for track in gpx . tracks : for segment in track . segments : for point in segment . points : t = utc_to_localtime ( point . time ) if local_time else point . time points . append ( ( t , point . latitude , point . longitude , point . elevation ) ) if len ( gpx . waypoints ) > 0 : for point in gpx . waypoints : t = utc_to_localtime ( point . time ) if local_time else point . time points . append ( ( t , point . latitude , point . longitude , point . elevation ) ) points . sort ( ) return points
Read location and time stamps from a track in a GPX file.

    Returns a list of tuples (time, lat, lon).

    GPX stores time in UTC, by default we assume your camera used the local time
    and convert accordingly.