getCluster
描述
🌐 Description
获取聚类
🌐 Get Cluster
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| Geojson | [特色合集](https://tools.ietf.org/html/rfc7946#section-3.3) | GeoJSON 功能 |
| 滤波器 | * | 用于 GeoJSON 属性的过滤器以获取 Cluster |
返回
🌐 Returns
FeatureCollection 按 GeoJSON 属性筛 选的单个集群
示例
🌐 Examples
var geojson = turf.featureCollection([
turf.point([0, 0], { "marker-symbol": "circle" }),
turf.point([2, 4], { "marker-symbol": "star" }),
turf.point([3, 6], { "marker-symbol": "star" }),
turf.point([5, 1], { "marker-symbol": "square" }),
turf.point([4, 2], { "marker-symbol": "circle" }),
]);
// Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
var clustered = turf.clustersKmeans(geojson);
// Retrieve first cluster (0)
var cluster = turf.getCluster(clustered, { cluster: 0 });
//= cluster
// Retrieve cluster based on custom properties
turf.getCluster(clustered, { "marker-symbol": "circle" }).length;
//= 2
turf.getCluster(clustered, { "marker-symbol": "square" }).length;
//= 1
安装
🌐 Installation
$ npm install @turf/clusters
import { getCluster } from "@turf/clusters";
const result = getCluster(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.getCluster(...);