# Module: ol/sphere

This documentation is for OpenLayers v10.9.0. The latest is v.

## ol/sphere

    import * as olSphere from 'ol/sphere';

### Functions

#### getArea(geometry, options){number}

sphere.js, line 178

      import {getArea} from 'ol/sphere';

  Get the spherical area of a geometry. This is the area (in meters) assuming that polygon edges are segments of great circles on a sphere.

  Name | Type | Description
  --- | --- | ---
  `geometry` | Geometry | A geometry.
  `options` | Options for the area calculation. By default, geometries are assumed to be in 'EPSG:3857'. You can change this by providing a `projection` option.
  Name | Type | Description
  --- | --- | ---
  `projection` | ProjectionLike (defaults to 'EPSG:3857') | Projection of the geometry. By default, the geometry is assumed to be in Web Mercator.
  `radius` | number (defaults to 6371008.8) | Sphere radius. By default, the mean Earth radius for the WGS84 ellipsoid is used.

  ##### Returns:

  The spherical area (in square meters).

#### getDistance(c1, c2, radius){number}

sphere.js, line 34

      import {getDistance} from 'ol/sphere';

  Get the great circle distance (in meters) between two geographic coordinates.

  Name | Type | Description
  --- | --- | ---
  `c1` | Array | Starting coordinate.
  `c2` | Array | Ending coordinate.
  `radius` | number | undefined | The sphere radius to use. Defaults to the Earth's mean radius using the WGS84 ellipsoid.

  ##### Returns:

  The great circle distance between the points (in meters).

#### getLength(geometry, options){number}

sphere.js, line 75

      import {getLength} from 'ol/sphere';

  Get the spherical length of a geometry. This length is the sum of the great circle distances between coordinates. For polygons, the length is the sum of all rings. For points, the length is zero. For multi-part geometries, the length is the sum of the length of each part.

  Name | Type | Description
  --- | --- | ---
  `geometry` | Geometry | A geometry.
  `options` | Options for the length calculation. By default, geometries are assumed to be in 'EPSG:3857'. You can change this by providing a `projection` option.
  Name | Type | Description
  --- | --- | ---
  `projection` | ProjectionLike (defaults to 'EPSG:3857') | Projection of the geometry. By default, the geometry is assumed to be in Web Mercator.
  `radius` | number (defaults to 6371008.8) | Sphere radius. By default, the mean Earth radius for the WGS84 ellipsoid is used.

  ##### Returns:

  The spherical length (in meters).

### Type Definitions

#### SphereMetricOptions{Object}

  Object literal with options for the `getLength` or `getArea` functions.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `projection` | ProjectionLike (defaults to 'EPSG:3857') | Projection of the geometry. By default, the geometry is assumed to be in Web Mercator.
  `radius` | number (defaults to 6371008.8) | Sphere radius. By default, the mean Earth radius for the WGS84 ellipsoid is used.