clustersDbscan
描述
🌐 Description
获取一组点并根据DBSCAN的数据聚类算法将它们划分为多个簇。
🌐 Takes a set of points and partition them into clusters according to DBSCAN's data clustering algorithm.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| 点 | FeatureCollection<Point> | 待聚类 |
| maxDistance | 数字 | 生成聚类时聚类中任意点之间的最大距离(默认单位为公里,见选项) |
| options? | 对象 | 可选参数 (默认 {}) |
| options.units? | [Units](docs/api/types/Units.mdx) | 其中表示为“maxDistance”,支持所有有效 Turf [Units](https://turf.nodejs.cn/docs/api/types/Units) (默认“kilometers”) |
| options.mutate? | 布尔 | 允许修改 GeoJSON 输入 (默认 false) |
| options.minPoints? | 数字 | 生成单个簇的最少点数,不满足此要求的点将被归类为“边缘”或“噪声”。 (默认 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(...);