No License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from

5.0 | 9 ratings Rate this file 36 Downloads (last 30 days) File Size: 1.86 KB File ID: #5256 Version: 1.0




15 Jun 2004 (Updated )

Calculate distance between two points on earth's surface given by latitude-longitude pair.

| Watch this File

File Information

Calculate distance between two points on earth's surface given by their latitude-longitude pair. Choose method 1 or 2. Method 1 uses plane approximation, only for points within several tens of kilometers; Method 2 calculates sphereic geodesic distance for points farther apart, but ignores flattening of the earth. Output is in km.


This file inspired Posdist, Heightprofile From Google Earth To 3 D Surface, and Pathdist.

MATLAB release MATLAB 6.5 (R13)
Other requirements Tested only on PCs.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (15)
10 Nov 2016 Shi Su

Shi Su (view profile)

29 Sep 2015 LR

LR (view profile)


Comment only
29 Sep 2015 LR

LR (view profile)

You could also use the built-in function DISTANCE from the Mapping Toolbox:
For the Earth:
ELLIPSOID = [6378.1 km (semimajor axis), 0.00335 (eccentricity)]

Comment only
03 Jun 2015 Isabel Lima

Thanks a lot. Great function!

04 Aug 2014 Stephen Cobeldick

Those are some of the strangest FEX tags that I have ever seen:

but i dont run the function
how many inputs i need
how many inputs i need 4

Comment only
14 Apr 2014 shen

shen (view profile)

Thank you very much.It is excellent but please check there might be a small error when there are only four input variables.

26 Sep 2013 Tom

Tom (view profile)

thank you, it works great!

Comment only
12 Sep 2012 star

star (view profile)

Thank you for the useful function

28 Jul 2011 Joachim

Good work

28 Mar 2011 Ioannis Daliakopoulos

line 36 should be

method = 1;

instead of

method == 1;

otherwise, very useful!

Comment only
22 Oct 2010 Rossella Blatt

Thanks. I was about to write the same function, but then I found it here: you made save some time! :)

10 Aug 2010 Rafael Palacios

Rafael Palacios (view profile)

18 Jun 2004 David Terr

That's much better! Keep up the good work.

18 Jun 2004 Langqiu Sun

Appologize for the former one. That's imcomplete. A new version has been uploaded. This should be OK.

Comment only
17 Jun 2004 David Terr

This looks like it could be a great program but as is, it doesn't do anything! In fact, I had to add a couple lines to the end to keep it from returning an error message. Please test your code before submitting it!


Contact us