5.0

5.0 | 2 ratings Rate this file 79 Downloads (last 30 days) File Size: 1.64 KB File ID: #38812
image thumbnail

LatLon distance

by

 

Find distance between two points based on latlon coordinates

| Watch this File

File Information
Description

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).

Acknowledgements

This file inspired Pathdist.

MATLAB release MATLAB 7.7 (R2008b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (2)
17 Mar 2014 Tianyang Li  
13 May 2013 Ian Shapiro

Simple but effective. Does just what it needs to do.

Contact us