Mapping Toolbox
  Go to function:
    Search    Help Desk 
distance    Examples   See Also

Compute distance between two points on the globe

Syntax

Background

Distance between two points can be calculated in two manners. For great circles, the distance is the shortest surface distance between two points. For rhumb lines, the distance is measured along the rhumb line passing through the two points, which is not, in general, the shortest surface distance between them. For more information on this distinction, see the "Geographic Measurement" section of Chapter 1, "Mapping Fundamentals," in the Mapping Toolbox User's Guide.

Description

dist = distance(pt1,pt2) calculates the great circle distance from pt1 to pt2. These two-column matrices should be of the form [latitude longitude]. The resulting distance is returned in terms of angle units of arc length (degrees by default).

dist = distance(lat1,lon1,lat2,lon2) performs the same calculation for two pairs of latitude and longitude matrices.

dist = distance(pt1,pt2,geoid) specifies the elliptical definition of the Earth to be used with the two-element geoid vector. The default geoid model is a unit sphere, which is sufficient for most applications. When a geoid is input, the resulting distance is given in terms of the distance units used in the geoid vector.

dist = distance(pt1,pt2,units) specifies the standard angle unit string. The default value is 'degrees'. These units are also the distance units of the result (e.g., degrees of arc length) unless a geoid vector is specified.

dist = distance(track,pt1,...) specifies whether great circle distances or rhumb line distances are desired. Great circle distances, the default, are indicated with the standard track string 'gc'. Rhumb line distances are indicated with the standard track string 'rh'.

Examples

Imagine a trip from Norfolk, Virginia (37ºN,76ºW), to Cape St. Vincent, Portugal (37ºN,9ºW), just outside the Straits of Gibraltar. The distance between these two points depends upon the track string selected. Using the pt1,pt2 notation, the two cases result in:

The difference between these two tracks is 1.992 degrees, or about 72 nautical miles. This represents about 2% of the total trip distance. The trade-off is that at the cost of those 72 miles, the entire trip can be made on a course of 090º, due east, while in order to follow the great circle path, the course must be changed continuously.

When a great circle and rhumb line coincide, the distances are the same. Using two points on the same meridian, this time in the lat1,lon1,lat2,lon2 notation:

The distances are the same, about 1800 nautical miles (there are about 60 nautical miles in a degree of arc length).

See Also

azimuth
Azimuth between two points on the globe
distdim
Convert distance units
reckon
New point with an azimuth and distance
track
track1
track2
Trace paths on the globe


[ Previous | Help Desk | Next ]