center
描述
🌐 Description
接受一个 Feature 或 FeatureCollection,并返回所有要素的绝对中心点。
🌐 Takes a Feature or FeatureCollection and returns the absolute center point of all features.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | GeoJSON | GeoJSON 居中 |
| options? | Object | 可选参数 (默认 {}) |
| options.properties? | Object | 将 GeoJSON 属性转换为点 (默认 {}) |
| options.bbox? | Object | 将 GeoJSON BBox 转换为点 (默认 {}) |
| options.id? | Object | 将 GeoJSON Id 转换为点 (默认 {}) |
返回
🌐 Returns
Feature<Point> 位于所有输入要素绝对中心点的点要素
示例
🌐 Examples
var features = turf.points([
[-97.522259, 35.4691],
[-97.502754, 35.463455],
[-97.508269, 35.463245],
]);
var center = turf.center(features);
安装
🌐 Installation
$ npm install @turf/center
import { center } from "@turf/center";
const result = center(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.center(...);