Calculating distance between two latitude longitude points

mjseim

Board Regular
Joined
Apr 5, 2005
Messages
88
I didn't think this would be so hard... but gezz! I'm not sure if this is more of a math question than an excel question, but since my weapon of choice is Excel I thought I'd give this a try.

I have been searching and searching for a formula that will derive the distance between two latitude longitude points.

My data is in the following format:
Lat Long
Origin: 44.844263 -92.914803
Destination: 44.822075 -92.912498

I have tried using the following formulas, which I found online, but it is clear I am using them incorrectly.

:::::Haversine formula:::::
R = earth’s radius (mean radius = 6,371km)
difflat = lat2 - lat1
difflong = long2 - long1
a = sin²(difflat/2) + cos(lat1) x cos(lat2) x sin²(diflong/2)
c = 2 x atan2(sqrt(a), sqrt(1-a))
d = R x c

:::::Spherical law of cosines:::::
d = acos(sin(lat1).sin(lat2)+cos(lat1).cos(lat2).cos(long2−long1)).R


If anyone can help me out with this I sure would appreciate it. I've already wasted hours trying to figure this out.
Thanks!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
OH I COULD KISS YOU!!!!

It appears to be working well. Perhaps I should get to know conversions a little better... or at least know what the heck I'm dealing with before I start diving into things like this.

Thank you very much.
 
Upvote 0
Or alternatively you could just use Pythagarus Method (Which will probably be close enough) i.e.

distance = square-root ( (Xb-Xa)2 + (Yb - Ya)2 )

Or as I have it in an Excel Formula

=IF(AL34="",0,(SQRT((VLOOKUP(LEFT(AL34,4),'Postcode data'!$A$2:$E$3221,2)-VLOOKUP(LEFT(AJ34,4),'Postcode data'!$A$2:$E$3221,2))^2+((VLOOKUP(LEFT(AL34,4),'Postcode data'!$A$2:$E$3221,3)-VLOOKUP(LEFT(AJ34,4),'Postcode data'!$A$2:$E$3221,3))^2))/1000)/1.6093)

Which looks up the X,Y details from a UK postcode (on another worksheet) and then works out the difference between the two.

Happy to send it to you if you want it.
 
Upvote 0
If anyone still stumbles on this thread as I just did, this formula seems easier these days for me.

Miles:
=ACOS(COS(RADIANS(90-Lat1)) * COS(RADIANS(90-Lat2)) + SIN(RADIANS(90-Lat1)) * SIN(RADIANS(90-Lat2)) * COS(RADIANS(Long1-Long2))) * 3959

Kilometers:
=ACOS(COS(RADIANS(90-Lat1)) * COS(RADIANS(90-Lat2)) + SIN(RADIANS(90-Lat1)) * SIN(RADIANS(90-Lat2)) * COS(RADIANS(Long1-Long2))) * 6371

Source:
macros - Driving distance between two coordinates - Stack Overflow
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top