Measuring the distance

In order to understand the elevation data chart, we need reference points along the x axis to help us determine the elevation along the route. We will calculate the mile splits along the route and place these at the appropriate location on the x axis of our charts:

# Locate the mile markers for i in range(1, int(round(total))): mile = 0 while mile < i: j += 1 mile += distances[j] measurements.append((int(mile), j)) j =- 1 # Set up labels for the mile points positions = [] miles = [] for m, i in measurements: pos = ((i*1.0)/len(elvs)) * 100 positions.append(pos) miles.append(m) # Position the mile marker labels along the x axis miles_label = chart.set_axis_labels(Axis.BOTTOM, miles) chart.set_axis_positions(miles_label, positions) ...

Get Learning Geospatial Analysis with Python - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.