4.27273

4.3 | 11 ratings Rate this file 77 downloads (last 30 days) File Size: 5.9 KB File ID: #5379

Geodetic distance on WGS84 earth ellipsoid

by Michael Kleder

 

30 Jun 2004 (Updated 01 Sep 2004)

No BSD License  

Rapidly computes the geodetic distance between coordinates on the ellipsoidal earth.

Download Now | Watch this File

File Information
Description

In 1975, Vincenty published a rapidly converging algorithm for computing the distance between points on an ellipsoidal earth. The algorithm is precise to within a few millimeters. Since then, his algorithm has since seen significant implementation in geodesy and engineering. After adjusting the algorithm to converge in all cases (the original suffers from convergence failure in a few outlying cases), I have provided it here in MATLAB form. The function itself does not require the Mapping Toolbox, but I have included a (commented-out) code section following the body of the function, which you can use if you have the Mapping Toolbox to compare the accuracy of this algorithm to spherical earth distances. Note that in that toolbox, the Mathworks uses a fast but somewhat less precise method for computing geodetic distances on an ellipsoid. This function will provide rapid, extremely precise results. Please see code comments for references.

MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (13)
05 Jul 2004 Fahad Al Mahmood

I have verified the output of this function with my Garmin MapSource software and I got the answers to be close enough. I found this function very useful.

06 Jul 2004 Ashish Misra

I have verified the output of this function with my Garmin MapSource software and I got the answers to be close enough. I found this function very useful

15 Jul 2005 Gabor Vali

Very helpful. Much more transparent than the equaazim.m routine.

22 Sep 2005 Gerald Dalley

Very nice. It would be convenient to allow the input coordinates to be vectors/matrices.

03 Oct 2005 Michael Kleder

See the following URL (Matlab File Exchange item #8607) for vectorized inputs and forward / reverse azimuth outputs, in addition to the Vincenty distance:
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8607&objectType=FILE

25 Oct 2005 Tro Han

Returns imaginary result for lon1=0 lon2=0.
Fix by preventing asin of # > 1 in alpha equation i.e.
alpha = asin(max(min(cos(U1)*cos(U2)*sin(lambda)/sin(sigma),1),-1));

31 Oct 2005 The Author

Thank you for your helpful comment. The problem you reported is actually addressed in the function which has superceded this one. The new function is vectorized, computes azimuth as well as distance, and features improved handling of anomalous cases. Please see
http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8607&objectType=FILE

29 Mar 2006 Frederic B.

Thanks!
The file has been really useful!

17 Jan 2007 Chuck B

Works great.

04 Nov 2007 Michael Draugelis

Works like a charm. I love it. Thanks for sharing!

19 Nov 2007 xzn dasds  
06 Mar 2008 Goran Nystrom  
30 Apr 2008 catur anindhito

thanx for sharing. That is very good

Please login to add a comment or rating.
Updates
01 Sep 2004

Minor typographical corrections.

Tag Activity for this File
Tag Applied By Date/Time
geodetic distance Michael Kleder 22 Oct 2008 07:25:52
wgs84 Michael Kleder 22 Oct 2008 07:25:52
earth Michael Kleder 22 Oct 2008 07:25:52
ellipsoidal Michael Kleder 22 Oct 2008 07:25:52
general Michael Kleder 22 Oct 2008 07:25:52
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com