NAME

Geod -- perform geodesic calculations


SYNOPSIS

Geod [ -i | -l lat1 lon1 azi1 ] [ -a ] [ -e a r ] [ -d ] [ -b ] [ -f ] [ -p prec ] [ --version | -h | --help ]


DESCRIPTION

The shortest path between two points on the ellipsoid at (lat1, lon1) and (lat2, lon2) is called the geodesic. Its length is s12 and the geodesic from point 1 to point 2 has azimuths azi1 and azi2 at the two end points. The reduced length of the geodesic, m12, is defined such that if the initial azimuth is perturbed by dazi1 (radians) then the second point is displaced by m12*dazi1 in the direction perpendicular to the geodesic. On a flat surface, we have m12 = s12.

Geod operates in one of three modes:

  1. By default, Geod accepts lines on the standard input containing lat1 lon1 azi1 s12 and prints lat2 lon2 azi2 m12 on standard output. This is the direct geodesic calculation.

  2. Command line arguments -l lat1 lon1 azi1 specify a geodesic line. Geod then accepts a sequence of s12 values (one per line) on standard input and prints lat2 lon2 azi2 m12 for each. This generates a sequence of points on a single geodesic.

  3. With the -i command line argument, Geod performs the inverse geodesic calculation. It reads lines containing lat1 lon1 lat2 lon2 and prints the corresponding values of azi1 azi2 s12 m12.


OPTIONS

-i

perform an inverse geodesic calculation (see 3 above).

-l

line mode (see 2 above); generate a sequence of points along the geodesic specified by lat1 lon1 azi1.

-a

arc mode; on input and output s12 is replaced by a12 the arc length (in degrees) on the auxiliary sphere. See AUXILIARY SPHERE.

-e

specify the ellipsoid via a r; the equatorial radius is a and the reciprocal flattening is r. Setting r = 0 results in a sphere. Specify r < 0 for a prolate ellipsoid. By default, the WGS84 ellipsoid is used, a = 6378137m, r = 298.257223563.

-d

output angles as degrees, minutes, seconds instead of decimal degrees.

-b

report the back azimuth at point 2 instead of the forward azimuth.

-f

full output; each line of output consists of 9 quantities: lat1 lon1 azi1 lat2 lon2 azi2 s12 a12 m12.

-p

set the precision to prec (default 3); prec is the precision relative to 1m. See PRECISION.

--version

print version.

-h

print usage.

--help

print full documentation.


INPUT

Geod measures all angles in degrees and all lengths (s12, m12) in meters. On input angles (latitude, longitude, azimuth, arc length) can be as decimal degrees or degrees (d), minutes ('), seconds ("). A decimal point can only appear in the least significant component and the designator (d, ', or ") for this component is optional; thus 40d30, 40d30', 40.5d, and 40.5 are all equivalent. By default, latitude precedes longitude for each point; however on input either may be given first by appending (or prepending) N or S to the latitude and E or W to the longitude. Azimuths are measured clockwise from north; however this may be overridden with E or W.


AUXILIARY SPHERE

Geodesics on the ellipsoid can be transferred to the auxiliary sphere on which the distance is measured in terms of the arc length a12 (measured in degrees) instead of s12. In terms of a12, 180 degrees is the distance from one equator crossing to the next or from the minimum latitude to the maximum latitude. Geodesics with a12 > 180 degrees do not correspond to shortest paths. With the -a flag, s12 (on both input and output) is replaced by a12. The -a flag does not affect the full output given by the -f flag (which always includes both s12 and a12). m12 is always given in meters.


PRECISION

prec gives precision of the output with prec = 0 giving 1m precision, prec = 3 giving 1mm precision, etc. prec is the number of digits after the decimal point for lengths. For decimal degrees, the number of digits after the decimal point is 5 + prec. For DMS (degree, minute, seconds) output, the number of digits after the decimal point in the seconds component is 1 + prec. The minimum value of prec is 0 and the maximum is 10.


ERRORS

An illegal line of input will print an error message to standard output beginning with ERROR: and causes Geod to return an exit code of 1. However, an error does not cause Geod to terminate; following lines will be converted.


EXAMPLES

Route from JFK Airport to Singapore Changi Airport:

   echo "40d38'23N" "073d46'44W" "01d21'33N" "103d59'22E" |
   Geod -i -d -p 0
   003d18'29.9" 177d29'09.2" 15347628 4302458

Waypoints on the route at intervals of 2000km:

   for ((i = 0; i <= 16; i += 2)); do echo ${i}000000;done |
   Geod -l "40d38'23N" "073d46'44W" "003d18'29.9" -d -p 0
   40d38'23.0"N 073d46'44.0"W 003d18'29.9" 0
   58d34'45.1"N 071d49'36.7"W 004d48'48.8" 1967419
   76d22'28.4"N 065d32'17.8"W 010d41'38.4" 3743642
   84d50'28.0"N 075d04'39.2"E 150d55'00.9" 5156905
   67d26'20.3"N 098d00'51.2"E 173d27'20.3" 6070415
   49d33'03.2"N 101d06'52.6"E 176d07'54.3" 6394568
   31d34'16.5"N 102d30'46.3"E 177d03'08.4" 6095725
   13d31'56.0"N 103d26'50.7"E 177d24'55.0" 5200700
   04d32'05.7"S 104d14'48.7"E 177d28'43.6" 3795596


SEE ALSO

Geod is a part of GeographicLib, http://geographiclib.sf.net. The algorithms are described in C. F. F. Karney, Geodesics on an ellipsoid of revolution, Feb. 2011; preprint http://arxiv.org/abs/1102.1215.


AUTHOR

Geod was written by Charles Karney.