dash.math.haversine

Returns the distances between latitude-longitude coordinates


Syntax



Description

distances = dash.math.haversine(coordinates)

Computes the distance between each latitude-longitude coordinate listed in a matrix. Note that the haversine function is agnostic to longitude coordinate systems. Thus, you may use longitudes on -180:180, or 0:360, or even a mix of both coordinate systems.

distances = dash.math.haversine(coordinates1, coordinates2)

Computes the distance between each coordinate in the first matrix and all the coordinates in the second matrix.


Input Arguments

coordinates

numeric matrix [nCoordinates x 2]
A set of latitude-longitude coordinates in decimal degrees. A numeric matrix with two columns. The first column is the latitude coordinates, and the second column is the longitude coordinates.

Output Arguments

distances

numeric matrix
The distance between each pair of coordinates in kilometers. If you input a single coordinate matrix, then distances is a symmetric matrix with one row and one column per latitude-longitude coordinate . If you input two coordinate matrices, then distances will have one row per coordinate in the first input, and one column per coordinate in the second input.