geosphere-package: Geosphere


This package implements functions that compute various aspects of distance, direction, area, etc. for geographic (geodetic) coordinates. Some of the functions are based on an ellipsoid (spheroid) model of the world, other functions use a (simpler, but less accuarate) spherical model. Functions using an ellipsoid can be recognized by having arguments to specify the ellipsoid's radius and flattening (a and f). By setting the value for f to zero, the ellipsoid becomes a sphere.

There are also functions to compute intersections of of rhumb lines. There are also functions to compute the distance between points and polylines, and to characterize spherical polygons; for random sampling on a sphere, and to compute daylength. See the vignette vignette('geosphere') for examples.

Geographic locations must be specified in latitude and longitude in degrees (NOT radians). Degrees are (obviously) in decimal notation. Thus 12 degrees, 30 minutes, 10 seconds = 12 + 30/60 + 10/3600 = 12.50278 degrees. The Southern and Western hemispheres have a negative sign.

The default unit of distance is meter; but this can be adjusted by supplying a different radius r to functions.

Directions are expressed in degrees (North = 0 and 360, East = 90, Sout = 180, and West = 270 degrees).


David Purdy, Bill Monahan and others for suggestions to improve the package.


Robert Hijmans, using code by C.F.F. Karney and Chris Veness; formulas by Ed Williams; and with contributions from George Wang, Elias Pipping and others. Maintainer: Robert J. Hijmans <>


C.F.F. Karney, 2013. Algorithms for geodesics, J. Geodesy 87: 43-55. Addenda: Also see

Questions? Problems? Suggestions? or email at

All documentation is copyright its authors; we didn't write any of that.