gpxplotter.gpxread

This module defines methods for reading data from GPX files.

gpxplotter.gpxread._get_gpx_text(track, tagname)[source]

Grab text from a given track.

gpxplotter.gpxread.approximate_velocity(distance, time)[source]

Calculate approximate velocities.

This method will calculate approximate velocities by finding a spline and its derivative.

Parameters:
  • distance (array_like) – Distances, measured as a function of time.

  • time (array_like) – The accompanying time stamps for the velocities.

gpxplotter.gpxread.extract_data(point, key, formatter)[source]

Extract data from a point.

Parameters:
  • key (string) – The xml field we are extracting data from.

  • formatter (callable) – A method we use to format/convert the data we extract.

gpxplotter.gpxread.get_distances(lat, lon)[source]

Get the spatial distance between time-ordered points.

Parameters:
  • lat (list of floats) – The latitudes.

  • lon (list of floats) – The longitudes.

Returns:

dist (list of floats) – The distances in meters.

gpxplotter.gpxread.get_point_data(point)[source]

Get basic information from a track point.

Parameters:

point (object like xml.dom.minidom.Element) – The point on the track we are extracting information from.

gpxplotter.gpxread.get_velocity(segment)[source]

Attempt to estimate the velocity.

Parameters:

segment (dict) – The raw data from the gpx file.

gpxplotter.gpxread.process_segment(segment, max_heart_rate=187)[source]

Add derived properties to the given segment.

Parameters:
  • segment (dict) – The raw data from the gpx file.

  • max_heart_rate (float, optional) – The maximum heart rate, used for the calculation of heart rate zones.

gpxplotter.gpxread.read_gpx_file(gpxfile, max_heart_rate=187)[source]

Read data from a given gpx file.

Parameters:
  • gpxfile (string) – The file to open and read.

  • max_heart_rate (integer (or float)) – The heart rate, used in calculation of heart rate zones.

Yields:

out (dict) – A dictionary containing the data read from each track in the file.

gpxplotter.gpxread.read_segment(segment)[source]

Read raw gpx-data for a segment.

Parameters:

segment (object like xml.dom.minidom.Element) – The segment we are about to read data from.

Returns:

out (dict) – The data read from the segment.

gpxplotter.gpxread.vincenty(point1, point2, tol=1e-12, maxitr=1000)[source]

Calculate distance between two lat/lon coordinates.

This calculation is based on the formula available from Wikipedia [1].

Parameters:
  • point1 (tuple of floats) – This is the first coordinate on the form: (lat, lon).

  • point2 (tuple of floats) – This is the second coordinate on the form: (lat, lon).

  • tol (float, optional) – The tolerance from convergence. The default value is taken from the wikipedia article.

  • maxitr (integer, optional) – The maximum number of iterations to perform.

References