centerOfMass
Description
Takes any Feature or a FeatureCollection and returns its center of mass using this formula: Centroid of Polygon.
Parameters
Name | Type | Description |
---|---|---|
geojson | GeoJSON | GeoJSON to be centered |
options? | Object | Optional Parameters (default {}) |
options.properties? | Object | Translate Properties to Feature (default {}) |
Returns
Examples
var polygon = turf.polygon([
[
[-81, 41],
[-88, 36],
[-84, 31],
[-80, 33],
[-77, 39],
[-81, 41],
],
]);
var center = turf.centerOfMass(polygon);
Installation
$ npm install @turf/center-of-mass
import { centerOfMass } from "@turf/center-of-mass";
const result = centerOfMass(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.centerOfMass(...);