Skip to main content
Version: 7.3.0

centerMean

描述

🌐 Description

接受一个 FeatureFeatureCollection 并返回平均中心。可以加权。

🌐 Takes a Feature or FeatureCollection and returns the mean center. Can be weighted.

参数

🌐 Parameters

名称类型描述
geojsonGeoJSONGeoJSON 居中
options?Object可选参数 (默认 {})
options.properties?Object将 GeoJSON 属性转换为点 (默认 {})
options.bbox?Object将 GeoJSON BBox 转换为点 (默认 {})
options.id?Object将 GeoJSON Id 转换为点 (默认 {})
options.weight?string用于加权中心的属性名称

返回

🌐 Returns

Feature<Point> 位于所有输入要素的平均中心点的点要素

示例

🌐 Examples

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);

安装

🌐 Installation

$ npm install @turf/center-mean

import { centerMean } from "@turf/center-mean";
const result = centerMean(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.centerMean(...);