Skip to main content
Version: 7.2.0

center

描述

¥Description

获取一个 特性FeatureCollection 对象并返回所有要素的绝对中心点。

¥Takes a Feature or FeatureCollection and returns the absolute center point of all features.

参数

¥Parameters

名称类型描述
geojsonGeoJSON待居中的 GeoJSON
options?对象可选参数(默认 {})
options.properties?对象将 GeoJSON 属性转换为点(默认 {})
options.bbox?对象将 GeoJSON BBox 转换为点(默认 {})
options.id?对象将 GeoJSON ID 转换为点(默认 {})

返回

¥Returns

特性<> 位于所有输入特性绝对中心的点特性

¥Feature<Point> a Point feature at the absolute center point of all input features

示例

¥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(...);