centroid
描述
¥Description
将质心计算为对象内所有顶点的平均值。
¥Computes the centroid as the mean of all vertices within the object.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
geojson | GeoJSON | 待居中的 GeoJSON |
options? | 对象 | 可选参数(默认 {}) |
options.properties? | 对象 | 一个用作 特性 属性的对象(默认为 {}) |
返回
¥Returns
¥Feature<Point> the centroid of the input object
示例
¥Examples
var polygon = turf.polygon([
[
[-81, 41],
[-88, 36],
[-84, 31],
[-80, 33],
[-77, 39],
[-81, 41],
],
]);
var centroid = turf.centroid(polygon);
安装
¥Installation
$ npm install @turf/centroid
import { centroid } from "@turf/centroid";
const result = centroid(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.centroid(...);