NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

# Calculating the distance (length) of an OSM Way

 1 The title pretty much says it all. Is there an accurate method to calculate the distance of an OSM way? asked 10 Feb '13, 19:45 Sadeer 176●8●9●14 accept rate: 0% 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? 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). (10 Feb '13, 20:12) RM87 2 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. (10 Feb '13, 20:24) Sadeer

 0 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 http://www.movable-type.co.uk/scripts/latlong.html answered 11 Feb '13, 12:01 sanser 695●38●39●55 accept rate: 5%
 0 Everything about routing or similar aims based on OSM data is collected in the OSM wiki about Routing. Search for opensource solutions to implement something in your project. answered 11 Feb '13, 12:29 stephan75 12.6k●5●56●210 accept rate: 6%

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

Question tags:

×710
×167
×63
×55
×45

question asked: 10 Feb '13, 19:45

question was seen: 12,520 times

last updated: 11 Feb '13, 12:29

### Related questions

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum