描述
接收一个 Feature 或 FeatureCollection,返回均值中心。可以加权。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | GeoJSON | 待居中的 GeoJSON |
| options? | Object | 可选参数 (默认 {}) |
| options.properties? | Object | 将 GeoJSON 属性转换到 Point (默认 {}) |
| options.bbox? | Object | 将 GeoJSON BBox 转换到 Point (默认 {}) |
| options.id? | Object | 将 GeoJSON Id 转换到 Point (默认 {}) |
| options.weight? | string | 用于加权中心的属性名称 |
返回值
Feature<Point> 位于所有输入要素均值中心点的 Point 要素
示例
javascript
var features = turf.featureCollection([
turf.point([-97.522259, 35.4691], { value: 10 }),
turf.point([-97.502754, 35.463455], { value: 3 }),
turf.point([-97.508269, 35.463245], { value: 5 }),
]);
var options = { weight: "value" };
var mean = turf.centerMean(features, options);安装
javascript
$ npm install @turf/center-mean
import { centerMean } from "@turf/center-mean";
const result = centerMean(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.centerMean(...);