clustersDbscan
描述
🌐 Description
获取一组点并根据DBSCAN的数据聚类算法将它们划分为多个簇。
🌐 Takes a set of points and partition them into clusters according to DBSCAN's data clustering algorithm.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| points | FeatureCollection<Point> | 要被聚类 |
| maxDistance | number | 生成簇的任意点之间的最大距离(默认单位为公里,见选项) |
| options? | Object | 可选参数 (默认 {}) |
| options.units? | Units | 其中 maxDistance 表示,支持所有有效的 Turf 单位 (默认 "kilometers") |
| options.mutate? | boolean | 允许修改 GeoJSON 输入 (默认 false) |
| options.minPoints? | number | 生成单个簇所需的最少点数,不符合此要求的点将被分类为“边缘”或“噪声”。(默认 3) |
返回
🌐 Returns
FeatureCollection<Point, DbscanProps> 聚类点,每个要素还关联两个附加属性:
- {number} cluster - 相关的 clusterId
- {string} dbscan - 它被分类为的点类型('核心'|'边缘'|'噪声')
示例
🌐 Examples
// create random points with random z-values in their properties
var points = turf.randomPoint(100, { bbox: [0, 30, 20, 50] });
var maxDistance = 100;
var clustered = turf.clustersDbscan(points, maxDistance);
安装
🌐 Installation
$ npm install @turf/clusters-dbscan
import { clustersDbscan } from "@turf/clusters-dbscan";
const result = clustersDbscan(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.clustersDbscan(...);