LatLon distance

版本 1.0.0.0 (1.6 KB) 作者: M Sohrabinia
Find distance between two points based on latlon coordinates
12.3K 次下载
更新时间 2012/10/30

查看许可证

This functions finds distance (in km) between two points on Earth using latitude-longitude coordinates of the two points. Distance is calculated using two distance funstions: Haversine and Pythagoran. The first output is based on Haversine function, which is more accurate especially for longer distances.

--Inputs:
latlon1: latlon of origin point [lat lon]
latlon2: latlon of destination point [lat lon]

--Outputs:
d1km: distance calculated by Haversine formula
d2km: distance calculated based on Pythagoran theorem

--Example 1, short distance:
latlon1=[-43 172];
latlon2=[-44 171];
[d1km d2km]=distance(latlon1,latlon2)
d1km =
137.365669065197 (km)
d2km =
137.368179013869 (km)
%d1km approximately equal to d2km

--Example 2, longer distance:
latlon1=[-43 172];
latlon2=[20 -108];
[d1km d2km]=distance(latlon1,latlon2)
d1km =
10734.8931427602 (km)
d2km =
31303.4535270825 (km)
d1km is significantly different from d2km (d2km is not able to work for longer distances).

引用格式

M Sohrabinia (2024). LatLon distance (https://www.mathworks.com/matlabcentral/fileexchange/38812-latlon-distance), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R2008b
兼容任何版本
平台兼容性
Windows macOS Linux
致谢

启发作品: pathdist

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
版本 已发布 发行说明
1.0.0.0