0

Goal: given a route as a set of ordered coordinates, measure the overall distance of the route and be able to access the coordinate pair at any given distance along the route.

Application: I'm building software to analyze driving routes and I would like to be able to get data for any particular section of the route that I want. For example, if I want to know the elevation profile between 50.3 and 58.7, I need the points from the route that are included between those distances.

Problem: I have tried this in Google Earth and various online route building websites like MapMyRide with absolutely horrible results. The process has been to take the file produced by the service, which is a set of points, and interact with the route based on the points in the file. When measured from start to finish, the distance is the same as the service claims. BUT, if I request a point at a distance along the route, using the same calculations for distance between points, I get a points that is anywhere from .5 to 2km off as compared to the distance from the service (basically, the km markers along the route).

Other info: This is a python project and I'm using Vincenty's ellipsoid to measure distance. This question is stemming from a conversation that started at Calculated distance doesn't match Google Earth.

2

Everything you need (I think!) is provided by my python package of geodesic routines available from PyPI. Documentation is available here. This is an improvement over Vincenty in that it's more accurate and the solution of the inverse problem is always found. In addition, several auxiliary quantities are computed. For details, see Algorithms for geodesics.

To support your requirement, you can compute intermediate points along a geodesic. Here's an example:

# Compute geodesic from Wellington (41.32S 174.81E) to Salamanca (40.96N
# 5.50W).  Then use Line + Position to compute the midpoint of the path.
# The result is lat = -45.71146, lon = -32.89884.

>>> import sys
>>> sys.path.append("/usr/local/lib/python/site-packages")
>>> from geographiclib.geodesic import Geodesic
>>> geod = Geodesic.WGS84.Inverse(-41.32, 174.81, 40.96, -5.50)
>>> line = Geodesic.WGS84.Line(geod['lat1'],geod['lon1'], geod['azi1'])
>>> line.Position(geod['s12']/2)
{'lat1': -41.32, 'lat2': -45.71146453982157, 's12': 9979839.63367691, 'a12': 89.71967827737355, 'azi2': 20.41865775243386, 'azi1': 161.06766998615882, 'lon1': 174.81, 'lon2': -32.89884451777209}
1

I see that you have a tag for ArcGIS, so you could use linear referencing with ArcGIS, similar tools are available in QGIS and both work well with Python.

Linear referencing would allow you to place a point ALONG the route instead of placing a point at a given distance from the starting point of your route. Vicenty is probably overkill for the distances that you mention (few hundred of km), but you could use an equidistant projection to minimize the length distortions (though equidistance is only true for selected directions).

0

Depending on the nature of your project, you may want to consider using a spatial database. You could probably whip up a solution to this relatively quickly using Python's psycopg2 with PostgreSQL + PostGIS.

Tutorial on psycopg2

Linear referencing in PostGIS

Without knowing more about your project though, it's hard to prescribe which of the available options is optimal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.