## Geodesic calculations for an ellipsoid done right

This page illustrates the geodesic routines available in JavaScript package geographiclib, which is documented here. The algorithms are considerably more accurate than Vincenty's method, and offer more functionality (an inverse method which never fails to converge, differential properties of the geodesic, and the area under a geodesic). The algorithms are derived in

Charles F. F. Karney,
Algorithms for geodesics,
J. Geodesy 87(1), 43–55 (Jan. 2013);
This page just provides a basic interface. Enter latitudes, longitudes, and azimuths as degrees and distances as meters using spaces or commas as separators. (Angles may be entered as decimal degrees or as degrees, minutes, and seconds, e.g. -20.51125, 20°30′40.5″S, S20d30'40.5", or -20:30:40.5.) The results are accurate to about 15 nanometers (or 0.1 m2 per vertex for areas). A slicker page where the geodesics are incorporated into Google Maps is given here. Basic online tools which provide similar capabilities are GeodSolve and Planimeter; these call a C++ backend. This page uses version of the geodesic code.

### Inverse problem

Find the shortest path between two points on the earth. The path is characterized by its length s12 and its azimuth at the two ends azi1 and azi2. See GeodSolve(1) for the definition of the quantities a12, m12, M12, M21, and S12. The sample calculation finds the shortest path between Wellington, New Zealand, and Salamanca, Spain. To perform the calculation, press the “COMPUTE” button.

Enter “lat1 lon1 lat2 lon2”:

input:

Output format:
Output precision:

status:

lat1 lon1 azi1:

lat2 lon2 azi2:

s12:

a12:

m12:

M12 M21:

S12:

### Direct problem

Find the destination traveling a given distance along a geodesic with a given azimuth at the starting point. The destination is characterized by its position lat2, lon2 and its azimuth at the destination azi2. See GeodSolve(1) for the definition of the quantities a12, m12, M12, M21, and S12. The sample calculation shows the result of travelling 10000 km NE from JFK airport. To perform the calculation, press the “COMPUTE” button.

Enter “lat1 lon1 azi1 s12”:

input:

Output format:
Output precision:

status:

lat1 lon1 azi1:

lat2 lon2 azi2:

s12:

a12:

m12:

M12 M21:

S12:

### Geodesic path

Find intermediate points along a geodesic. In addition to specifying the endpoints, give ds12, the maximum distance between the intermediate points and maxk, the maximum number of intervals the geodesic is broken into. The output gives a sequence of positions lat, lon together with the corresponding azimuths azi. The sample shows the path from JFK to Singapore's Changi Airport at about 1000 km intervals. (In this example, the path taken by Google Earth deviates from the shortest path by about 2.9 km.) To perform the calculation, press the “COMPUTE” button.

Enter “lat1 lon1 lat2 lon2 ds12 maxk”:

input:

Output format:
Output precision:

status:

points (lat lon azi):

### Polygon area

Find the perimeter and area of a polygon whose sides are geodesics. The polygon must be simple (i.e., must not intersect itself). (There's no need to ensure that the polygon is closed.) Counter-clockwise traversal of the polygon results in a positive area. The polygon can encircle one or both poles. The sample gives the approximate perimeter (in m) and area (in m2) of Antarctica. (For this example, Google Earth Pro returns an area which is 30 times too large! However this is a little unfair, since Google Earth has no concept of polygons which encircle a pole.) If the polyline option is selected then just the length of the line joining the points is returned. To perform the calculation, press the “COMPUTE” button.

Enter points, one per line, as “lat lon”:

points (lat lon):

Treat points as:

status:

number perimeter area:

Charles Karney <charles@karney.com> (2015-08-12)

Geographiclib Sourceforge