Skip to main content
Version: 7.2.0

centerOfMass

描述

¥Description

获取任意 特性FeatureCollection 对象并使用以下公式返回其 质心多边形质心

¥Takes any Feature or a FeatureCollection and returns its center of mass using this formula: Centroid of Polygon.

参数

¥Parameters

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

返回

¥Returns

特性<> 质心

¥Feature<Point> the center of mass

示例

¥Examples

var polygon = turf.polygon([
[
[-81, 41],
[-88, 36],
[-84, 31],
[-80, 33],
[-77, 39],
[-81, 41],
],
]);

var center = turf.centerOfMass(polygon);

安装

¥Installation

$ npm install @turf/center-of-mass

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

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