# clustersKmeans

Takes a set of points and partition them into clusters using the k-mean. It uses the k-means algorithm
使用K-Means聚类算法将一组点划分为簇。

参数

参数 类型 描述
points FeatureCollection <Point> 被聚类点
options Object 可选参数:见下文

options选项

属性 类型 默认值 描述
numberOfClusters number Math.sqrt(numberOfPoints/2) 将生成的簇数
mutate boolean false 允许修改GeoJSON输入(如果为真,性能将显著提高)

返回

FeatureCollection <Point> - 每个要素都有额外的两个属性与聚类点相关联:

示例

// 在它们的属性中创建具有随机z值的随机点
var points = turf.randomPoint(100, {bbox: [0, 30, 20, 50]});
var options = {numberOfClusters: 7};
var clustered = turf.clustersKmeans(points, options);
Last Updated: 6/23/2023, 10:33:35 PM