Skip to main content

centroid

The mean of a geometry's vertices, as a map position. This is a plain average of the positions (a ring's repeated closing position counts once), so a polygon with many vertices along one side leans towards that side. It is not the centre of mass, and for a concave shape it may fall outside it.

This is a function exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import { centroid } from "@mapcairn/core";

function centroid(input: GeometryInput): LatLng;

Parameters​

  • input (GeometryInput)

Returns​

LatLng

Throws​

  • GeometryError of kind invalid for a malformed geometry, empty when it has no positions.

See also​

Source: packages/core/src/geometry/queries.ts:66