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

how to calculate a distance between two locations?

asked 19 Jan '13, 16:06

Marco%20Schumann's gravatar image

Marco Schumann
accept rate: 0%


A bit more information about what you're trying to do here would help.

Do you want the great circle distance between two locations on the earth's surface, or the travel distance from one to another calculated by a router for a particular mode of transport?

(20 Jan '13, 13:54) SomeoneElse ♦

This is not an OpenStreetMap specific question.

In software, a formula called the Haversine formula is used to compute the distance between two points. You will likely find example implementations in your programming language of choice if you search for them on the web.

permanent link

answered 19 Jan '13, 16:48

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

You can use a router e.g. an online one like yournavigation or OSRM, of course these can only be used for small amount of lookups (see OSRM api policy), and they candisapear at any moment. If you want to lookup lots of these distances you will have to install something of your own, installing Gosmore is quite easy, OSRM I've never tried to install.

These are the URLs to use.,18.0572&loc=58.4162,15.5523&alt=false

it's very simple to extract the distance from these results.

 OSRM: "route_summary":{"total_distance":199988
YOURS:  <kml><Document><distance>200.510334</distance>

See OSRM server API for more info

permanent link

answered 24 Jan '13, 11:47

emj's gravatar image

accept rate: 15%

edited 19 Jun '13, 12:33

If you need to calculate a distance often some mapping software will help. I have recently installed an OSM map into Garmin's Basecamp and Mapsource both, or either can be downloaded free. They are very similar and I'm not sure why both exist or which is best. They're good and are great for route planning and sending maps,way points and routes (plotted or auto routing) to my Garmins along roads or paths.

permanent link

answered 22 Jan '13, 10:14

andy%20mackey's gravatar image

andy mackey
accept rate: 4%

sorry mapsource may not work without a garmin device but basecamp will, I think,

(22 Jan '13, 10:24) andy mackey

(22 Jan '13, 10:28) andy mackey

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • 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:


question asked: 19 Jan '13, 16:06

question was seen: 12,354 times

last updated: 19 Jun '13, 12:33

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