# gsw_distance

    spherical earth distance between points in long,
    lat coordinates at a given pressure

## Contents

- USAGE:
- DESCRIPTION:
- INPUT:
- OUTPUT:
- EXAMPLE:
- AUTHOR:
- VERSION NUMBER:
- REFERENCE:

## USAGE:

    distance = gsw_distance(long,lat,{p})

## DESCRIPTION:

    Calculates the distance in metres between successive points in the
    vectors long and lat, computed using the Haversine formula on a
    spherical earth of radius 6,371 km, being the radius of a sphere having
    the same volume as Earth. For a sperical Earth of radius 6,371,000 m,
    one nautical mile is 1,853.2488 m, thus one degree of latitude is
    111,194.93 m.
    Note. Distances are probably good to better than 1% of the "true"
      distance on the ellipsoidal earth.

## INPUT:

    long  =  longitude in decimal degress                     [ 0 ... +360 ]
                                                        or [ -180 ... +180 ]
    lat   =  latitude in decimal degress north               [ -90 ... +90 ]

    OPTIONAL:

    p     =  sea pressure ( default is 0 )                          [ dbar ]
             ( i.e. absolute pressure - 10.1325 dbar )

    lat and long need to have the same dimensions, Mx1 or 1xN or MxN.
    p, if provided, may have dimensions 1x1 or Mx1 or 1xN or MxN,
    where lat & long are Mx1 or 1xN or MxN.

## OUTPUT:

    distance  =  Distance between points on a spherical                [ m ]
                 Earth at pressure (p)
    Note. The output is in m not km.

## EXAMPLE:

    Example 1  Station 1 is at (-35, 159) & Station 2 is at (35, 220)
       long = [159 220]
       lat = [-35 35]

     distance = gsw_distance(long,lat)

     distance =

       1.003097465291600e+007

    Example 2  Station 1 is at (-35, 159) & Station 2 is at (35, 220),
     the pressure at  Station 1 is 200 and at Station 2 it is 1000 dbar.
       long = [159 220]
       lat = [-35 35]
       p = [200 1000]

    Note that the pressures are not equal, we therefore calculate the
    distance between stations at the mid pressure.

     distance = gsw_distance(long,lat,p)

     distance =

      1.003066163927133e+007

    Example 3 If the locations are entered as pairs in a column it will
    calculate the distances between each pairs of stations (points).
       long = [159 220; 140 200]
       lat = [-35 35; 20 45]
       p = [200 1000]

     distance = gsw_distance(long,lat,p)

     distance =

         1.003066163927133e+007
        6.11164218568001e+006

## AUTHOR:

    6th November, 2000 by Rich Pawlowicz               [ help@teos-10.org ]
    Note. This function was extracted from Rich Pawlowicz's m_map package,
      which is available from http://www.eos.ubc.ca/~rich/map.html

    MODIFIED:
      28th July, 2010 by Paul Barker and Trevor McDougall.

## VERSION NUMBER:

    3.02 (17th November, 2012)

## REFERENCE:

    Rich Pawlowicz's m_map package.  http://www.eos.ubc.ca/~rich/map.html

    The software is available from http://www.TEOS-10.org