---
name: "geodesic"
section: "3"
platform: "linux"
package: "libproj-dev"
version: "5.2.0-1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/geodesic/3"
---

# geodesic(3)

initialize an ellipsoid geod\_direct geod\_gendirect - the direct geodesic problem geod\_inverse geod\_geninverse - the inverse geodesic problem geod\_lineinit geod\_directline geod\_gendirectline geod\_inverseline - initialize a geodesic line geod\_setdistance geod\_gensetdistance - set distance to reference point geod\_position geod\_genposition - a position on a geodesic line geod\_polygon\_init - initialize a polygon geod\_addpoint geod\_addedge - add to a polygon geod\_polygon\_compute geod\_polygon\_testpoint geod\_polygon\_testedge - compute properties of polygon geod\_polygon\_clear - clear polygon geod\_polygonarea - the area of a polygon

## NAME

**geod\_init** - initialize an ellipsoid\
 **geod\_direct geod\_gendirect** - the direct geodesic problem\
 **geod\_inverse geod\_geninverse** - the inverse geodesic problem\
 **geod\_lineinit geod\_directline geod\_gendirectline geod\_inverseline** - initialize a geodesic line\
 **geod\_setdistance geod\_gensetdistance** - set distance to reference point\
 **geod\_position geod\_genposition** - a position on a geodesic line\
 **geod\_polygon\_init** - initialize a polygon\
 **geod\_addpoint geod\_addedge** - add to a polygon\
 **geod\_polygon\_compute geod\_polygon\_testpoint geod\_polygon\_testedge** - compute properties of polygon\
 **geod\_polygon\_clear** - clear polygon\
 **geod\_polygonarea** - the area of a polygon\

## SYNOPSIS

```
#include <geodesic.h>
and link against the proj library.
```

## DESCRIPTION

This library is a port of the geodesic routines in the C++ library, GeographicLib, to C.  It solves the direct and inverse geodesic problems on an ellipsoid of revolution.  In addition, the reduced length of a geodesic and the area between a geodesic and the equator can be computed.  The results are accurate to round off for \|*f*\| \< 1/50, where *f* is the flattening.  Note that the geodesic routines measure angles (latitudes, longitudes, and azimuths) in degrees, unlike the rest of the **proj** library, which uses radians.  The documentation for this library is included in geodesic.h.  A formatted version of the documentation is available at https://geographiclib.sourceforge.io/1.49/C.  Detailed documentation of the interface is given at https://geographiclib.sourceforge.io/1.49/C/geodesic\_8h.html.

## EXAMPLE

The following program reads in lines with the coordinates for two points in decimal degrees (*lat1*, *lon1*, *lat2*, *lon2*) and prints out *azi1*, *azi2*, *s12* for the geodesic line between each pair of points on the WGS84 ellipsoid.  (N.B. *azi2* is the forward azimuth at point 2.)

```
#include <stdio.h>
#include <geodesic.h>
int main() {
  double a = 6378137, f = 1/298.257223563; /* WGS84 */
  double lat1, lon1, azi1, lat2, lon2, azi2, s12;
  struct geod_geodesic g;
  geod_init(&g, a, f);
  while (scanf("%lf %lf %lf %lf",
               &lat1, &lon1, &lat2, &lon2) == 4) {
    geod_inverse(&g, lat1, lon1, lat2, lon2,
                 &s12, &azi1, &azi2);
    printf("%.8f %.8f %.3f\n", azi1, azi2, s12);
  }
  return 0;
}
```

## LIBRARY

libproj.a - library of projections and support procedures

## SEE ALSO

Full online documentation for **[geodesic(3)](/geodesic/3.md)**,\
 https://geographiclib.sourceforge.io/1.49/C\
 https://geographiclib.sourceforge.io/1.49/C/geodesic\_8h.html

**[geod(1)](/geod/1.md)**

**GeographicLib**, https://geographiclib.sourceforge.io

The **GeodesicExact** class in GeographicLib solves the geodesic problems in terms of elliptic integrals; the results are accurate for arbitrary *f*.

C. F. F. Karney, *Algorithms for Geodesics*,\
 J. Geodesy **87**, 43-55 (2013);\
 DOI: https://doi.org/10.1007/s00190-012-0578-z\
 https://geographiclib.sourceforge.io/geod-addenda.html

*A geodesic bibliography*,\
 https://geographiclib.sourceforge.io/geodesic-papers/biblio.html

The Wikipedia page, *Geodesics on an ellipsoid*,\
 https://en.wikipedia.org/wiki/Geodesics\_on\_an\_ellipsoid

## BUGS

A list of known bugs can found at https://github.com/OSGeo/proj.4/issues where new bug reports can be submitted too.

## HOME PAGE

https://proj4.org/
