centerOfMass
描述
🌐 Description
接受任何 Feature 或 FeatureCollection,并使用此公式计算其 质心: 多边形的中心。
🌐 Takes any Feature or a FeatureCollection and returns its center of mass using this formula: Centroid of Polygon.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | GeoJSON | GeoJSON 居中 |
| options? | Object | 可选参数 (默认 {}) |
| options.properties? | Object | 将属性转换为功能 (默认 {}) |
返回
🌐 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(...);