# centroid

Takes one or more features and calculates the centroid using the mean of all vertices. This lessens the effect of small islands and artifacts when calculating the centroid of a set of polygons.
接受一个或多个 feature,并使用所有顶点的平均值计算质心。这在计算一组多边形的质心时可以减少小岛屿和人工制品的影响。

参数

参数 类型 描述
geojson GeoJSON GeoJSON to be centered
properties Object 一个用作Feature属性的对象

返回

Feature <Point> - 输入 Feature 的质心

示例

// 注意:polygon首尾坐标要一致
var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);

var centroid = turf.centroid(polygon);
Last Updated: 6/23/2023, 10:33:35 PM