Answers to: Calculating the distance (length) of an OSM Wayhttps://help.openstreetmap.org/questions/19799/calculating-the-distance-length-of-an-osm-way<p>The title pretty much says it all. Is there an accurate method to calculate the distance of an OSM way?</p>enMon, 11 Feb 2013 12:29:37 +0000Answer by stephan75https://help.openstreetmap.org/questions/19799/calculating-the-distance-length-of-an-osm-way/19822<p>Everything about routing or similar aims based on OSM data is collected in the OSM wiki about <a href="http://wiki.openstreetmap.org/wiki/Routing">Routing</a>.</p>
<p>Search for opensource solutions to implement something in your project.</p>stephan75Mon, 11 Feb 2013 12:29:37 +0000https://help.openstreetmap.org/questions/19799/calculating-the-distance-length-of-an-osm-way/19822Answer by sanserhttps://help.openstreetmap.org/questions/19799/calculating-the-distance-length-of-an-osm-way/19820<p>For any consecutive points P1(lat1,lon1), P2(lat2,lon2) in a "way" calculate the corresponding P1(x1,y1,z1), P2(v2,y2,z2) and so calculate the cetral angle "alpha" in the corresponding main circle (use the scalar or vector product of the 2 position vectors). The diatnce is then dist=alpha*R (R, the major semi-axis of the WGS'84 sphere).
You can find many related articles by searching, for example using "latitude longitude distance" key-words, like the following one
<a href="http://www.movable-type.co.uk/scripts/latlong.html">http://www.movable-type.co.uk/scripts/latlong.html</a></p>sanserMon, 11 Feb 2013 12:01:14 +0000https://help.openstreetmap.org/questions/19799/calculating-the-distance-length-of-an-osm-way/19820Comment by Sadeer on Sadeer's questionhttps://help.openstreetmap.org/questions/19799/calculating-the-distance-length-of-an-osm-way#19801<p>I'm given an OSM XML file and would like to calculate the distances of the ways in the XML file. It's needed for my academic project which is to implement a routing engine.</p>SadeerSun, 10 Feb 2013 20:24:08 +0000https://help.openstreetmap.org/questions/19799/calculating-the-distance-length-of-an-osm-way#19801Comment by RM87 on Sadeer's questionhttps://help.openstreetmap.org/questions/19799/calculating-the-distance-length-of-an-osm-way#19800<p>Please add some details like what accuracy do you need.
What is your source data? Is it a way id, an osm file or do you have these ways in a database? </p>
<p>Also knowing what you need to do, would help to write a good answer (otherwise you might get a perfectly good formula for calculating the length with pencil and paper).</p>RM87Sun, 10 Feb 2013 20:12:54 +0000https://help.openstreetmap.org/questions/19799/calculating-the-distance-length-of-an-osm-way#19800