# 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.050955616404136e+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.050922853324439e+007

## AUTHOR:

    6th November, 2000 by Rich Pawlowicz             [ help_gsw@csiro.au ]
    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:

    2.0 (23rd July, 2010)

## 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