Hi,

I am having trouble getting an accurate distance between two lat/lon coordinates. This site, give the correct result which is 2 meters.

http://boulter.com/gps/distance/?from=53.1330940+-1.1843660&to=53.1331060+-1.1843260&units=k

Here is the code I am using :

This return 2.98 meters as do a lot of other online versions of this calculation. the correct distance is actually 2 meters. Am I missing something?

My coords are :

FROM

53.1330940 -1.1843660

TO

53.1331060 -1.1843260

ANy help appreciated!

Thanks

I am having trouble getting an accurate distance between two lat/lon coordinates. This site, give the correct result which is 2 meters.

http://boulter.com/gps/distance/?from=53.1330940+-1.1843660&to=53.1331060+-1.1843260&units=k

Here is the code I am using :

```
function distance(lat1, lon1, lat2, lon2, 'K') {
var radlat1 = Math.PI * lat1/180
var radlat2 = Math.PI * lat2/180
var radlon1 = Math.PI * lon1/180
var radlon2 = Math.PI * lon2/180
var theta = lon1-lon2
var radtheta = Math.PI * theta/180
var dist = Math.sin(radlat1) * Math.sin(radlat2) + Math.cos(radlat1) * Math.cos(radlat2) * Math.cos(radtheta);
dist = Math.acos(dist)
dist = dist * 180/Math.PI
dist = dist * 60 * 1.1515
if (unit=="K") { dist = dist * 1.609344 }
if (unit=="N") { dist = dist * 0.8684 }
return dist
}
```

This return 2.98 meters as do a lot of other online versions of this calculation. the correct distance is actually 2 meters. Am I missing something?

My coords are :

FROM

53.1330940 -1.1843660

TO

53.1331060 -1.1843260

ANy help appreciated!

Thanks

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

http://jsbin.com/vumikayi/1/edit

Open in new window