## Geodesic calculations for an ellipsoid done right

This page illustrates the geodesic routines available in JavaScript package geographiclib, the geodesic routines in GeographicLib ( documentation). 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);
> DOI: 10.1007/s00190-012-0578-z (pdf); addenda: geod-addenda.html.

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.

Jump to:

- Inverse problem
- Direct problem
- Geodesic path
- Polygon area
- Geodesic lines, circles, and envelopes in Google Maps

### 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: decimal degrees degrees minutes seconds
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: decimal degrees degrees minutes seconds
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: decimal degrees degrees minutes seconds
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):
-63.1 -58 -72.9 -74 -71.9 -102 -74.9 -102 -74.3 -131 -77.5 -163 -77.4 163 -71.7 172 -65.9 140 -65.7 113 -66.6 88 -66.9 59 -69.8 25 -70.0 -4 -71.0 -14 -77.3 -33 -77.9 -46 -74.7 -61

Treat points as: polygon polyline

status:

number perimeter area:

Geographiclib Sourceforge