clustersDbscan
描述
¥Description
获取一组 points,并根据 DBSCAN 算法 数据聚类算法将其划分为不同的聚类。
¥Takes a set of points and partition them into clusters according to DBSCAN's data clustering algorithm.
参数
¥Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| points | FeatureCollection<点> | 待聚类 |
| maxDistance | number | 生成聚类的聚类中任意点之间的最大距离(默认为公里,请参阅选项) |
| options? | 对象 | 可选参数(默认值:) |
| options.units? | 单位 | maxDistance 的表示方式,支持所有有效的 Turf 单位(默认 "kilometers") |
| options.mutate? | boolean | 允许 GeoJSON 输入发生修改(默认为 false) |
| options.minPoints? | number | 生成单个聚类所需的最小点数,不符合此要求的点将被归类为 'edge' 或 'noise'。(默认 3) |
返回
¥Returns
FeatureCollection<点, DbscanProps> 聚类点,每个要素还关联两个附加属性:
¥FeatureCollection<Point, DbscanProps> Clustered Points with an additional two properties associated to each Feature:
-
{number} cluster - the associated clusterId
-
{string} dbscan - type of point it has been classified as ('core'|'edge'|'noise')
示例
¥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(...);