@turf/clusters-kmeans 6.5.0 → 7.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -8
- package/dist/es/index.js +1 -2
- package/dist/js/index.d.ts +2 -2
- package/dist/js/index.js +5 -8
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -7,14 +7,15 @@
|
|
|
7
7
|
Takes a set of [points][1] and partition them into clusters using the k-mean .
|
|
8
8
|
It uses the [k-means algorithm][2]
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
### Parameters
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- `options.numberOfClusters` **[number][6]** numberOfClusters that will be generated (optional, default `Math.sqrt(numberOfPoints/2)`)
|
|
15
|
-
- `options.mutate` **[boolean][7]** allows GeoJSON input to be mutated (significant performance increase if true) (optional, default `false`)
|
|
12
|
+
* `points` **[FeatureCollection][3]<[Point][4]>** to be clustered
|
|
13
|
+
* `options` **[Object][5]** Optional parameters (optional, default `{}`)
|
|
16
14
|
|
|
17
|
-
**
|
|
15
|
+
* `options.numberOfClusters` **[number][6]** numberOfClusters that will be generated (optional, default `Math.sqrt(numberOfPoints/2)`)
|
|
16
|
+
* `options.mutate` **[boolean][7]** allows GeoJSON input to be mutated (significant performance increase if true) (optional, default `false`)
|
|
17
|
+
|
|
18
|
+
### Examples
|
|
18
19
|
|
|
19
20
|
```javascript
|
|
20
21
|
// create random points with random z-values in their properties
|
|
@@ -26,8 +27,8 @@ var clustered = turf.clustersKmeans(points, options);
|
|
|
26
27
|
var addToMap = [clustered];
|
|
27
28
|
```
|
|
28
29
|
|
|
29
|
-
Returns **[FeatureCollection][3]
|
|
30
|
-
|
|
30
|
+
Returns **[FeatureCollection][3]<[Point][4]>** Clustered Points with an additional two properties associated to each Feature:* {number} cluster - the associated clusterId
|
|
31
|
+
* {\[number, number]} centroid - Centroid of the cluster \[Longitude, Latitude]
|
|
31
32
|
|
|
32
33
|
[1]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
33
34
|
|
package/dist/es/index.js
CHANGED
|
@@ -22,8 +22,7 @@ import skmeans from "skmeans";
|
|
|
22
22
|
* //addToMap
|
|
23
23
|
* var addToMap = [clustered];
|
|
24
24
|
*/
|
|
25
|
-
function clustersKmeans(points, options) {
|
|
26
|
-
if (options === void 0) { options = {}; }
|
|
25
|
+
function clustersKmeans(points, options = {}) {
|
|
27
26
|
// Default Params
|
|
28
27
|
var count = points.features.length;
|
|
29
28
|
options.numberOfClusters =
|
package/dist/js/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FeatureCollection, Point,
|
|
2
|
-
export declare type KmeansProps =
|
|
1
|
+
import { FeatureCollection, Point, GeoJsonProperties } from "geojson";
|
|
2
|
+
export declare type KmeansProps = GeoJsonProperties & {
|
|
3
3
|
cluster?: number;
|
|
4
4
|
centroid?: [number, number];
|
|
5
5
|
};
|
package/dist/js/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const clone_1 = tslib_1.__importDefault(require("@turf/clone"));
|
|
5
|
+
const meta_1 = require("@turf/meta");
|
|
6
|
+
const skmeans_1 = tslib_1.__importDefault(require("skmeans"));
|
|
9
7
|
/**
|
|
10
8
|
* Takes a set of {@link Point|points} and partition them into clusters using the k-mean .
|
|
11
9
|
* It uses the [k-means algorithm](https://en.wikipedia.org/wiki/K-means_clustering)
|
|
@@ -27,8 +25,7 @@ var skmeans_1 = __importDefault(require("skmeans"));
|
|
|
27
25
|
* //addToMap
|
|
28
26
|
* var addToMap = [clustered];
|
|
29
27
|
*/
|
|
30
|
-
function clustersKmeans(points, options) {
|
|
31
|
-
if (options === void 0) { options = {}; }
|
|
28
|
+
function clustersKmeans(points, options = {}) {
|
|
32
29
|
// Default Params
|
|
33
30
|
var count = points.features.length;
|
|
34
31
|
options.numberOfClusters =
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/clusters-kmeans",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf clusters-kmeans module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -51,17 +51,17 @@
|
|
|
51
51
|
"docs": "node ../../scripts/generate-readmes",
|
|
52
52
|
"test": "npm-run-all test:*",
|
|
53
53
|
"test:tape": "ts-node -r esm test.js",
|
|
54
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
54
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@turf/centroid": "^
|
|
58
|
-
"@turf/clusters": "^
|
|
59
|
-
"@turf/random": "^
|
|
57
|
+
"@turf/centroid": "^7.0.0-alpha.0",
|
|
58
|
+
"@turf/clusters": "^7.0.0-alpha.0",
|
|
59
|
+
"@turf/random": "^7.0.0-alpha.0",
|
|
60
60
|
"@types/skmeans": "^0.11.2",
|
|
61
61
|
"@types/tape": "*",
|
|
62
62
|
"benchmark": "*",
|
|
63
63
|
"chromatism": "*",
|
|
64
|
-
"concaveman": "
|
|
64
|
+
"concaveman": "^1.2.1",
|
|
65
65
|
"load-json-file": "*",
|
|
66
66
|
"matrix-to-grid": "*",
|
|
67
67
|
"npm-run-all": "*",
|
|
@@ -72,11 +72,12 @@
|
|
|
72
72
|
"write-json-file": "*"
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@turf/clone": "^
|
|
76
|
-
"@turf/helpers": "^
|
|
77
|
-
"@turf/invariant": "^
|
|
78
|
-
"@turf/meta": "^
|
|
79
|
-
"skmeans": "0.9.7"
|
|
75
|
+
"@turf/clone": "^7.0.0-alpha.0",
|
|
76
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
77
|
+
"@turf/invariant": "^7.0.0-alpha.0",
|
|
78
|
+
"@turf/meta": "^7.0.0-alpha.0",
|
|
79
|
+
"skmeans": "0.9.7",
|
|
80
|
+
"tslib": "^2.3.0"
|
|
80
81
|
},
|
|
81
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
82
83
|
}
|