@turf/standard-deviational-ellipse 7.1.0-alpha.7 → 7.1.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 +27 -29
- package/dist/cjs/index.cjs +30 -26
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +50 -21
- package/dist/esm/index.d.ts +50 -21
- package/dist/esm/index.js +30 -26
- package/dist/esm/index.js.map +1 -1
- package/package.json +13 -10
package/README.md
CHANGED
|
@@ -4,70 +4,68 @@
|
|
|
4
4
|
|
|
5
5
|
## standardDeviationalEllipse
|
|
6
6
|
|
|
7
|
-
Takes a
|
|
7
|
+
Takes a collection of features and returns a standard deviational ellipse,
|
|
8
8
|
also known as a “directional distribution.” The standard deviational ellipse
|
|
9
9
|
aims to show the direction and the distribution of a dataset by drawing
|
|
10
|
-
an ellipse that contains about one standard deviation’s worth (
|
|
10
|
+
an ellipse that contains about one standard deviation’s worth (\~ 70%) of the
|
|
11
11
|
data.
|
|
12
12
|
|
|
13
|
-
This module mirrors the functionality of [Directional Distribution][
|
|
14
|
-
in ArcGIS and the [QGIS Standard Deviational Ellipse Plugin][
|
|
13
|
+
This module mirrors the functionality of [Directional Distribution][1]
|
|
14
|
+
in ArcGIS and the [QGIS Standard Deviational Ellipse Plugin][2]
|
|
15
15
|
|
|
16
16
|
**Bibliography**
|
|
17
17
|
|
|
18
18
|
• Robert S. Yuill, “The Standard Deviational Ellipse; An Updated Tool for
|
|
19
19
|
Spatial Description,” *Geografiska Annaler* 53, no. 1 (1971): 28–39,
|
|
20
|
-
doi:{@link [https://doi.org/10.2307/490885|10.2307/490885}][
|
|
20
|
+
doi:{@link [https://doi.org/10.2307/490885|10.2307/490885}][3].
|
|
21
21
|
|
|
22
22
|
• Paul Hanly Furfey, “A Note on Lefever’s “Standard Deviational Ellipse,”
|
|
23
23
|
*American Journal of Sociology* 33, no. 1 (1927): 94—98,
|
|
24
|
-
doi:{@link [https://doi.org/10.1086/214336|10.1086/214336}][
|
|
24
|
+
doi:{@link [https://doi.org/10.1086/214336|10.1086/214336}][4].
|
|
25
25
|
|
|
26
26
|
### Parameters
|
|
27
27
|
|
|
28
|
-
* `points` **[FeatureCollection][
|
|
29
|
-
* `options` **[Object][
|
|
28
|
+
* `points` **[FeatureCollection][5]<[Point][6]>** GeoJSON points
|
|
29
|
+
* `options` **[Object][7]** Optional parameters (optional, default `{}`)
|
|
30
30
|
|
|
31
|
-
* `options.weight` **[string][
|
|
32
|
-
* `options.steps` **[number][
|
|
33
|
-
* `options.properties` **[Object][
|
|
31
|
+
* `options.weight` **[string][8]?** the property name used to weight the center
|
|
32
|
+
* `options.steps` **[number][9]** number of steps for the polygon (optional, default `64`)
|
|
33
|
+
* `options.properties` **[Object][7]** properties to pass to the resulting ellipse (optional, default `{}`)
|
|
34
34
|
|
|
35
35
|
### Examples
|
|
36
36
|
|
|
37
37
|
```javascript
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const bbox = [-74, 40.72, -73.98, 40.74];
|
|
39
|
+
const points = turf.randomPoint(400, {bbox: bbox});
|
|
40
|
+
const sdEllipse = turf.standardDeviationalEllipse(points);
|
|
41
41
|
|
|
42
42
|
//addToMap
|
|
43
|
-
|
|
43
|
+
const addToMap = [points, sdEllipse];
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
Returns **[Feature][
|
|
46
|
+
Returns **[Feature][10]<[Polygon][11]>** an elliptical Polygon that includes approximately 1 SD of the dataset within it.
|
|
47
47
|
|
|
48
|
-
[1]:
|
|
48
|
+
[1]: http://desktop.arcgis.com/en/arcmap/10.3/tools/spatial-statistics-toolbox/directional-distribution.htm
|
|
49
49
|
|
|
50
|
-
[2]: http://
|
|
50
|
+
[2]: http://arken.nmbu.no/~havatv/gis/qgisplugins/SDEllipse/
|
|
51
51
|
|
|
52
|
-
[3]:
|
|
52
|
+
[3]: https://doi.org/10.2307/490885|10.2307/490885}
|
|
53
53
|
|
|
54
|
-
[4]: https://doi.org/10.
|
|
54
|
+
[4]: https://doi.org/10.1086/214336|10.1086/214336}
|
|
55
55
|
|
|
56
|
-
[5]: https://
|
|
56
|
+
[5]: https://tools.ietf.org/html/rfc7946#section-3.3
|
|
57
57
|
|
|
58
|
-
[6]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
58
|
+
[6]: https://tools.ietf.org/html/rfc7946#section-3.1.2
|
|
59
59
|
|
|
60
|
-
[7]: https://
|
|
60
|
+
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
61
61
|
|
|
62
|
-
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
62
|
+
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
63
63
|
|
|
64
|
-
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
64
|
+
[9]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
65
65
|
|
|
66
|
-
[10]: https://
|
|
66
|
+
[10]: https://tools.ietf.org/html/rfc7946#section-3.2
|
|
67
67
|
|
|
68
|
-
[11]: https://tools.ietf.org/html/rfc7946#section-3.
|
|
69
|
-
|
|
70
|
-
[12]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
68
|
+
[11]: https://tools.ietf.org/html/rfc7946#section-3.1.6
|
|
71
69
|
|
|
72
70
|
<!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
|
|
73
71
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
|
|
2
2
|
var _meta = require('@turf/meta');
|
|
3
3
|
var _invariant = require('@turf/invariant');
|
|
4
4
|
var _helpers = require('@turf/helpers');
|
|
@@ -6,39 +6,42 @@ var _centermean = require('@turf/center-mean');
|
|
|
6
6
|
var _pointswithinpolygon = require('@turf/points-within-polygon');
|
|
7
7
|
var _ellipse = require('@turf/ellipse');
|
|
8
8
|
function standardDeviationalEllipse(points, options) {
|
|
9
|
+
var _a;
|
|
9
10
|
options = options || {};
|
|
10
11
|
if (!_helpers.isObject.call(void 0, options))
|
|
11
12
|
throw new Error("options is invalid");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const steps = options.steps || 64;
|
|
14
|
+
const weightTerm = options.weight;
|
|
15
|
+
const properties = options.properties || {};
|
|
15
16
|
if (!_helpers.isNumber.call(void 0, steps))
|
|
16
17
|
throw new Error("steps must be a number");
|
|
17
18
|
if (!_helpers.isObject.call(void 0, properties))
|
|
18
19
|
throw new Error("properties must be a number");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const numberOfFeatures = _meta.coordAll.call(void 0, points).length;
|
|
21
|
+
const meanCenter = _centermean.centerMean.call(void 0, points, { weight: weightTerm });
|
|
22
|
+
let xDeviationSquaredSum = 0;
|
|
23
|
+
let yDeviationSquaredSum = 0;
|
|
24
|
+
let xyDeviationSum = 0;
|
|
24
25
|
_meta.featureEach.call(void 0, points, function(point) {
|
|
25
|
-
var
|
|
26
|
-
|
|
26
|
+
var _a2;
|
|
27
|
+
const weight = weightTerm ? ((_a2 = point.properties) == null ? void 0 : _a2[weightTerm]) || 1 : 1;
|
|
28
|
+
const deviation = getDeviations(_invariant.getCoords.call(void 0, point), _invariant.getCoords.call(void 0, meanCenter));
|
|
27
29
|
xDeviationSquaredSum += Math.pow(deviation.x, 2) * weight;
|
|
28
30
|
yDeviationSquaredSum += Math.pow(deviation.y, 2) * weight;
|
|
29
31
|
xyDeviationSum += deviation.x * deviation.y * weight;
|
|
30
32
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
const bigA = xDeviationSquaredSum - yDeviationSquaredSum;
|
|
34
|
+
const bigB = Math.sqrt(Math.pow(bigA, 2) + 4 * Math.pow(xyDeviationSum, 2));
|
|
35
|
+
const bigC = 2 * xyDeviationSum;
|
|
36
|
+
const theta = Math.atan((bigA + bigB) / bigC);
|
|
37
|
+
const thetaDeg = theta * 180 / Math.PI;
|
|
38
|
+
let sigmaXsum = 0;
|
|
39
|
+
let sigmaYsum = 0;
|
|
40
|
+
let weightsum = 0;
|
|
39
41
|
_meta.featureEach.call(void 0, points, function(point) {
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
+
var _a2;
|
|
43
|
+
const weight = weightTerm ? ((_a2 = point.properties) == null ? void 0 : _a2[weightTerm]) || 1 : 1;
|
|
44
|
+
const deviation = getDeviations(_invariant.getCoords.call(void 0, point), _invariant.getCoords.call(void 0, meanCenter));
|
|
42
45
|
sigmaXsum += Math.pow(
|
|
43
46
|
deviation.x * Math.cos(theta) - deviation.y * Math.sin(theta),
|
|
44
47
|
2
|
|
@@ -49,19 +52,19 @@ function standardDeviationalEllipse(points, options) {
|
|
|
49
52
|
) * weight;
|
|
50
53
|
weightsum += weight;
|
|
51
54
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const sigmaX = Math.sqrt(2 * sigmaXsum / weightsum);
|
|
56
|
+
const sigmaY = Math.sqrt(2 * sigmaYsum / weightsum);
|
|
57
|
+
const theEllipse = _ellipse.ellipse.call(void 0, meanCenter, sigmaX, sigmaY, {
|
|
55
58
|
units: "degrees",
|
|
56
59
|
angle: thetaDeg,
|
|
57
60
|
steps,
|
|
58
61
|
properties
|
|
59
62
|
});
|
|
60
|
-
|
|
63
|
+
const pointsWithinEllipse = _pointswithinpolygon.pointsWithinPolygon.call(void 0,
|
|
61
64
|
points,
|
|
62
65
|
_helpers.featureCollection.call(void 0, [theEllipse])
|
|
63
66
|
);
|
|
64
|
-
|
|
67
|
+
const standardDeviationalEllipseProperties = {
|
|
65
68
|
meanCenterCoordinates: _invariant.getCoords.call(void 0, meanCenter),
|
|
66
69
|
semiMajorAxis: sigmaX,
|
|
67
70
|
semiMinorAxis: sigmaY,
|
|
@@ -69,6 +72,7 @@ function standardDeviationalEllipse(points, options) {
|
|
|
69
72
|
angle: thetaDeg,
|
|
70
73
|
percentageWithinEllipse: 100 * _meta.coordAll.call(void 0, pointsWithinEllipse).length / numberOfFeatures
|
|
71
74
|
};
|
|
75
|
+
theEllipse.properties = (_a = theEllipse.properties) != null ? _a : {};
|
|
72
76
|
theEllipse.properties.standardDeviationalEllipse = standardDeviationalEllipseProperties;
|
|
73
77
|
return theEllipse;
|
|
74
78
|
}
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"names":["_a"],"mappings":"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","sourcesContent":["import {\n FeatureCollection,\n Feature,\n Position,\n Polygon,\n GeoJsonProperties,\n Point,\n} from \"geojson\";\nimport { coordAll, featureEach } from \"@turf/meta\";\nimport { getCoords } from \"@turf/invariant\";\nimport { featureCollection, isObject, isNumber } from \"@turf/helpers\";\nimport { centerMean } from \"@turf/center-mean\";\nimport { pointsWithinPolygon } from \"@turf/points-within-polygon\";\nimport { ellipse } from \"@turf/ellipse\";\n\ndeclare interface SDEProps {\n meanCenterCoordinates: Position;\n semiMajorAxis: number;\n semiMinorAxis: number;\n numberOfFeatures: number;\n angle: number;\n percentageWithinEllipse: number;\n}\n\ndeclare interface StandardDeviationalEllipse extends Feature<Polygon> {\n properties: {\n standardDeviationalEllipse: SDEProps;\n [key: string]: any;\n } | null;\n}\n\n/**\n * Takes a collection of features and returns a standard deviational ellipse,\n * also known as a “directional distribution.” The standard deviational ellipse\n * aims to show the direction and the distribution of a dataset by drawing\n * an ellipse that contains about one standard deviation’s worth (~ 70%) of the\n * data.\n *\n * This module mirrors the functionality of {@link http://desktop.arcgis.com/en/arcmap/10.3/tools/spatial-statistics-toolbox/directional-distribution.htm|Directional Distribution}\n * in ArcGIS and the {@link http://arken.nmbu.no/~havatv/gis/qgisplugins/SDEllipse/|QGIS Standard Deviational Ellipse Plugin}\n *\n * **Bibliography**\n *\n * • Robert S. Yuill, “The Standard Deviational Ellipse; An Updated Tool for\n * Spatial Description,” _Geografiska Annaler_ 53, no. 1 (1971): 28–39,\n * doi:{@link https://doi.org/10.2307/490885|10.2307/490885}.\n *\n * • Paul Hanly Furfey, “A Note on Lefever’s “Standard Deviational Ellipse,”\n * _American Journal of Sociology_ 33, no. 1 (1927): 94—98,\n * doi:{@link https://doi.org/10.1086/214336|10.1086/214336}.\n *\n *\n * @name standardDeviationalEllipse\n * @param {FeatureCollection<Point>} points GeoJSON points\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.weight] the property name used to weight the center\n * @param {number} [options.steps=64] number of steps for the polygon\n * @param {Object} [options.properties={}] properties to pass to the resulting ellipse\n * @returns {Feature<Polygon>} an elliptical Polygon that includes approximately 1 SD of the dataset within it.\n * @example\n *\n * const bbox = [-74, 40.72, -73.98, 40.74];\n * const points = turf.randomPoint(400, {bbox: bbox});\n * const sdEllipse = turf.standardDeviationalEllipse(points);\n *\n * //addToMap\n * const addToMap = [points, sdEllipse];\n *\n */\nfunction standardDeviationalEllipse(\n points: FeatureCollection<Point>,\n options?: {\n properties?: GeoJsonProperties;\n weight?: string;\n steps?: number;\n }\n): StandardDeviationalEllipse {\n // Optional params\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n const steps = options.steps || 64;\n const weightTerm = options.weight;\n const properties = options.properties || {};\n\n // Validation:\n if (!isNumber(steps)) throw new Error(\"steps must be a number\");\n if (!isObject(properties)) throw new Error(\"properties must be a number\");\n\n // Calculate mean center & number of features:\n const numberOfFeatures = coordAll(points).length;\n const meanCenter = centerMean(points, { weight: weightTerm });\n\n // Calculate angle of rotation:\n // [X, Y] = mean center of all [x, y].\n // theta = arctan( (A + B) / C )\n // A = sum((x - X)^2) - sum((y - Y)^2)\n // B = sqrt(A^2 + 4(sum((x - X)(y - Y))^2))\n // C = 2(sum((x - X)(y - Y)))\n\n let xDeviationSquaredSum = 0;\n let yDeviationSquaredSum = 0;\n let xyDeviationSum = 0;\n\n featureEach(points, function (point) {\n // weightTerm or point.properties might be undefined, hence this check.\n const weight = weightTerm ? point.properties?.[weightTerm] || 1 : 1;\n const deviation = getDeviations(getCoords(point), getCoords(meanCenter));\n xDeviationSquaredSum += Math.pow(deviation.x, 2) * weight;\n yDeviationSquaredSum += Math.pow(deviation.y, 2) * weight;\n xyDeviationSum += deviation.x * deviation.y * weight;\n });\n\n const bigA = xDeviationSquaredSum - yDeviationSquaredSum;\n const bigB = Math.sqrt(Math.pow(bigA, 2) + 4 * Math.pow(xyDeviationSum, 2));\n const bigC = 2 * xyDeviationSum;\n const theta = Math.atan((bigA + bigB) / bigC);\n const thetaDeg = (theta * 180) / Math.PI;\n\n // Calculate axes:\n // sigmaX = sqrt((1 / n - 2) * sum((((x - X) * cos(theta)) - ((y - Y) * sin(theta)))^2))\n // sigmaY = sqrt((1 / n - 2) * sum((((x - X) * sin(theta)) - ((y - Y) * cos(theta)))^2))\n let sigmaXsum = 0;\n let sigmaYsum = 0;\n let weightsum = 0;\n featureEach(points, function (point) {\n // weightTerm or point.properties might be undefined, hence this check.\n const weight = weightTerm ? point.properties?.[weightTerm] || 1 : 1;\n const deviation = getDeviations(getCoords(point), getCoords(meanCenter));\n sigmaXsum +=\n Math.pow(\n deviation.x * Math.cos(theta) - deviation.y * Math.sin(theta),\n 2\n ) * weight;\n sigmaYsum +=\n Math.pow(\n deviation.x * Math.sin(theta) + deviation.y * Math.cos(theta),\n 2\n ) * weight;\n weightsum += weight;\n });\n\n const sigmaX = Math.sqrt((2 * sigmaXsum) / weightsum);\n const sigmaY = Math.sqrt((2 * sigmaYsum) / weightsum);\n\n const theEllipse: Feature<Polygon> = ellipse(meanCenter, sigmaX, sigmaY, {\n units: \"degrees\",\n angle: thetaDeg,\n steps: steps,\n properties: properties,\n });\n const pointsWithinEllipse = pointsWithinPolygon(\n points,\n featureCollection([theEllipse])\n );\n const standardDeviationalEllipseProperties = {\n meanCenterCoordinates: getCoords(meanCenter),\n semiMajorAxis: sigmaX,\n semiMinorAxis: sigmaY,\n numberOfFeatures: numberOfFeatures,\n angle: thetaDeg,\n percentageWithinEllipse:\n (100 * coordAll(pointsWithinEllipse).length) / numberOfFeatures,\n };\n // Make sure properties object exists.\n theEllipse.properties = theEllipse.properties ?? {};\n theEllipse.properties.standardDeviationalEllipse =\n standardDeviationalEllipseProperties;\n\n // We have added the StandardDeviationalEllipse specific properties, so\n // confirm this to Typescript with a cast.\n return theEllipse as StandardDeviationalEllipse;\n}\n\n/**\n * Get x_i - X and y_i - Y\n *\n * @private\n * @param {Position} coordinates Array of [x_i, y_i]\n * @param {Position} center Array of [X, Y]\n * @returns {Object} { x: n, y: m }\n */\nfunction getDeviations(coordinates: Position, center: Position) {\n return {\n x: coordinates[0] - center[0],\n y: coordinates[1] - center[1],\n };\n}\n\nexport { standardDeviationalEllipse, SDEProps, StandardDeviationalEllipse };\nexport default standardDeviationalEllipse;\n"]}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,32 +1,61 @@
|
|
|
1
1
|
import { Position, Feature, Polygon, FeatureCollection, Point, GeoJsonProperties } from 'geojson';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* http://turfjs.org/docs/#standarddeviational-ellipse
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
3
|
declare interface SDEProps {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
meanCenterCoordinates: Position;
|
|
5
|
+
semiMajorAxis: number;
|
|
6
|
+
semiMinorAxis: number;
|
|
7
|
+
numberOfFeatures: number;
|
|
8
|
+
angle: number;
|
|
9
|
+
percentageWithinEllipse: number;
|
|
14
10
|
}
|
|
15
|
-
|
|
16
11
|
declare interface StandardDeviationalEllipse extends Feature<Polygon> {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
properties: {
|
|
13
|
+
standardDeviationalEllipse: SDEProps;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
} | null;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Takes a collection of features and returns a standard deviational ellipse,
|
|
19
|
+
* also known as a “directional distribution.” The standard deviational ellipse
|
|
20
|
+
* aims to show the direction and the distribution of a dataset by drawing
|
|
21
|
+
* an ellipse that contains about one standard deviation’s worth (~ 70%) of the
|
|
22
|
+
* data.
|
|
23
|
+
*
|
|
24
|
+
* This module mirrors the functionality of {@link http://desktop.arcgis.com/en/arcmap/10.3/tools/spatial-statistics-toolbox/directional-distribution.htm|Directional Distribution}
|
|
25
|
+
* in ArcGIS and the {@link http://arken.nmbu.no/~havatv/gis/qgisplugins/SDEllipse/|QGIS Standard Deviational Ellipse Plugin}
|
|
26
|
+
*
|
|
27
|
+
* **Bibliography**
|
|
28
|
+
*
|
|
29
|
+
* • Robert S. Yuill, “The Standard Deviational Ellipse; An Updated Tool for
|
|
30
|
+
* Spatial Description,” _Geografiska Annaler_ 53, no. 1 (1971): 28–39,
|
|
31
|
+
* doi:{@link https://doi.org/10.2307/490885|10.2307/490885}.
|
|
32
|
+
*
|
|
33
|
+
* • Paul Hanly Furfey, “A Note on Lefever’s “Standard Deviational Ellipse,”
|
|
34
|
+
* _American Journal of Sociology_ 33, no. 1 (1927): 94—98,
|
|
35
|
+
* doi:{@link https://doi.org/10.1086/214336|10.1086/214336}.
|
|
36
|
+
*
|
|
37
|
+
*
|
|
38
|
+
* @name standardDeviationalEllipse
|
|
39
|
+
* @param {FeatureCollection<Point>} points GeoJSON points
|
|
40
|
+
* @param {Object} [options={}] Optional parameters
|
|
41
|
+
* @param {string} [options.weight] the property name used to weight the center
|
|
42
|
+
* @param {number} [options.steps=64] number of steps for the polygon
|
|
43
|
+
* @param {Object} [options.properties={}] properties to pass to the resulting ellipse
|
|
44
|
+
* @returns {Feature<Polygon>} an elliptical Polygon that includes approximately 1 SD of the dataset within it.
|
|
45
|
+
* @example
|
|
46
|
+
*
|
|
47
|
+
* const bbox = [-74, 40.72, -73.98, 40.74];
|
|
48
|
+
* const points = turf.randomPoint(400, {bbox: bbox});
|
|
49
|
+
* const sdEllipse = turf.standardDeviationalEllipse(points);
|
|
50
|
+
*
|
|
51
|
+
* //addToMap
|
|
52
|
+
* const addToMap = [points, sdEllipse];
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
declare function standardDeviationalEllipse(points: FeatureCollection<Point>, options?: {
|
|
26
56
|
properties?: GeoJsonProperties;
|
|
27
57
|
weight?: string;
|
|
28
58
|
steps?: number;
|
|
29
|
-
|
|
30
|
-
): StandardDeviationalEllipse;
|
|
59
|
+
}): StandardDeviationalEllipse;
|
|
31
60
|
|
|
32
61
|
export { type SDEProps, type StandardDeviationalEllipse, standardDeviationalEllipse as default, standardDeviationalEllipse };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,32 +1,61 @@
|
|
|
1
1
|
import { Position, Feature, Polygon, FeatureCollection, Point, GeoJsonProperties } from 'geojson';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* http://turfjs.org/docs/#standarddeviational-ellipse
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
3
|
declare interface SDEProps {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
meanCenterCoordinates: Position;
|
|
5
|
+
semiMajorAxis: number;
|
|
6
|
+
semiMinorAxis: number;
|
|
7
|
+
numberOfFeatures: number;
|
|
8
|
+
angle: number;
|
|
9
|
+
percentageWithinEllipse: number;
|
|
14
10
|
}
|
|
15
|
-
|
|
16
11
|
declare interface StandardDeviationalEllipse extends Feature<Polygon> {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
properties: {
|
|
13
|
+
standardDeviationalEllipse: SDEProps;
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
} | null;
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Takes a collection of features and returns a standard deviational ellipse,
|
|
19
|
+
* also known as a “directional distribution.” The standard deviational ellipse
|
|
20
|
+
* aims to show the direction and the distribution of a dataset by drawing
|
|
21
|
+
* an ellipse that contains about one standard deviation’s worth (~ 70%) of the
|
|
22
|
+
* data.
|
|
23
|
+
*
|
|
24
|
+
* This module mirrors the functionality of {@link http://desktop.arcgis.com/en/arcmap/10.3/tools/spatial-statistics-toolbox/directional-distribution.htm|Directional Distribution}
|
|
25
|
+
* in ArcGIS and the {@link http://arken.nmbu.no/~havatv/gis/qgisplugins/SDEllipse/|QGIS Standard Deviational Ellipse Plugin}
|
|
26
|
+
*
|
|
27
|
+
* **Bibliography**
|
|
28
|
+
*
|
|
29
|
+
* • Robert S. Yuill, “The Standard Deviational Ellipse; An Updated Tool for
|
|
30
|
+
* Spatial Description,” _Geografiska Annaler_ 53, no. 1 (1971): 28–39,
|
|
31
|
+
* doi:{@link https://doi.org/10.2307/490885|10.2307/490885}.
|
|
32
|
+
*
|
|
33
|
+
* • Paul Hanly Furfey, “A Note on Lefever’s “Standard Deviational Ellipse,”
|
|
34
|
+
* _American Journal of Sociology_ 33, no. 1 (1927): 94—98,
|
|
35
|
+
* doi:{@link https://doi.org/10.1086/214336|10.1086/214336}.
|
|
36
|
+
*
|
|
37
|
+
*
|
|
38
|
+
* @name standardDeviationalEllipse
|
|
39
|
+
* @param {FeatureCollection<Point>} points GeoJSON points
|
|
40
|
+
* @param {Object} [options={}] Optional parameters
|
|
41
|
+
* @param {string} [options.weight] the property name used to weight the center
|
|
42
|
+
* @param {number} [options.steps=64] number of steps for the polygon
|
|
43
|
+
* @param {Object} [options.properties={}] properties to pass to the resulting ellipse
|
|
44
|
+
* @returns {Feature<Polygon>} an elliptical Polygon that includes approximately 1 SD of the dataset within it.
|
|
45
|
+
* @example
|
|
46
|
+
*
|
|
47
|
+
* const bbox = [-74, 40.72, -73.98, 40.74];
|
|
48
|
+
* const points = turf.randomPoint(400, {bbox: bbox});
|
|
49
|
+
* const sdEllipse = turf.standardDeviationalEllipse(points);
|
|
50
|
+
*
|
|
51
|
+
* //addToMap
|
|
52
|
+
* const addToMap = [points, sdEllipse];
|
|
53
|
+
*
|
|
54
|
+
*/
|
|
55
|
+
declare function standardDeviationalEllipse(points: FeatureCollection<Point>, options?: {
|
|
26
56
|
properties?: GeoJsonProperties;
|
|
27
57
|
weight?: string;
|
|
28
58
|
steps?: number;
|
|
29
|
-
|
|
30
|
-
): StandardDeviationalEllipse;
|
|
59
|
+
}): StandardDeviationalEllipse;
|
|
31
60
|
|
|
32
61
|
export { type SDEProps, type StandardDeviationalEllipse, standardDeviationalEllipse as default, standardDeviationalEllipse };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// index.
|
|
1
|
+
// index.ts
|
|
2
2
|
import { coordAll, featureEach } from "@turf/meta";
|
|
3
3
|
import { getCoords } from "@turf/invariant";
|
|
4
4
|
import { featureCollection, isObject, isNumber } from "@turf/helpers";
|
|
@@ -6,39 +6,42 @@ import { centerMean } from "@turf/center-mean";
|
|
|
6
6
|
import { pointsWithinPolygon } from "@turf/points-within-polygon";
|
|
7
7
|
import { ellipse } from "@turf/ellipse";
|
|
8
8
|
function standardDeviationalEllipse(points, options) {
|
|
9
|
+
var _a;
|
|
9
10
|
options = options || {};
|
|
10
11
|
if (!isObject(options))
|
|
11
12
|
throw new Error("options is invalid");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const steps = options.steps || 64;
|
|
14
|
+
const weightTerm = options.weight;
|
|
15
|
+
const properties = options.properties || {};
|
|
15
16
|
if (!isNumber(steps))
|
|
16
17
|
throw new Error("steps must be a number");
|
|
17
18
|
if (!isObject(properties))
|
|
18
19
|
throw new Error("properties must be a number");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
const numberOfFeatures = coordAll(points).length;
|
|
21
|
+
const meanCenter = centerMean(points, { weight: weightTerm });
|
|
22
|
+
let xDeviationSquaredSum = 0;
|
|
23
|
+
let yDeviationSquaredSum = 0;
|
|
24
|
+
let xyDeviationSum = 0;
|
|
24
25
|
featureEach(points, function(point) {
|
|
25
|
-
var
|
|
26
|
-
|
|
26
|
+
var _a2;
|
|
27
|
+
const weight = weightTerm ? ((_a2 = point.properties) == null ? void 0 : _a2[weightTerm]) || 1 : 1;
|
|
28
|
+
const deviation = getDeviations(getCoords(point), getCoords(meanCenter));
|
|
27
29
|
xDeviationSquaredSum += Math.pow(deviation.x, 2) * weight;
|
|
28
30
|
yDeviationSquaredSum += Math.pow(deviation.y, 2) * weight;
|
|
29
31
|
xyDeviationSum += deviation.x * deviation.y * weight;
|
|
30
32
|
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
const bigA = xDeviationSquaredSum - yDeviationSquaredSum;
|
|
34
|
+
const bigB = Math.sqrt(Math.pow(bigA, 2) + 4 * Math.pow(xyDeviationSum, 2));
|
|
35
|
+
const bigC = 2 * xyDeviationSum;
|
|
36
|
+
const theta = Math.atan((bigA + bigB) / bigC);
|
|
37
|
+
const thetaDeg = theta * 180 / Math.PI;
|
|
38
|
+
let sigmaXsum = 0;
|
|
39
|
+
let sigmaYsum = 0;
|
|
40
|
+
let weightsum = 0;
|
|
39
41
|
featureEach(points, function(point) {
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
+
var _a2;
|
|
43
|
+
const weight = weightTerm ? ((_a2 = point.properties) == null ? void 0 : _a2[weightTerm]) || 1 : 1;
|
|
44
|
+
const deviation = getDeviations(getCoords(point), getCoords(meanCenter));
|
|
42
45
|
sigmaXsum += Math.pow(
|
|
43
46
|
deviation.x * Math.cos(theta) - deviation.y * Math.sin(theta),
|
|
44
47
|
2
|
|
@@ -49,19 +52,19 @@ function standardDeviationalEllipse(points, options) {
|
|
|
49
52
|
) * weight;
|
|
50
53
|
weightsum += weight;
|
|
51
54
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
const sigmaX = Math.sqrt(2 * sigmaXsum / weightsum);
|
|
56
|
+
const sigmaY = Math.sqrt(2 * sigmaYsum / weightsum);
|
|
57
|
+
const theEllipse = ellipse(meanCenter, sigmaX, sigmaY, {
|
|
55
58
|
units: "degrees",
|
|
56
59
|
angle: thetaDeg,
|
|
57
60
|
steps,
|
|
58
61
|
properties
|
|
59
62
|
});
|
|
60
|
-
|
|
63
|
+
const pointsWithinEllipse = pointsWithinPolygon(
|
|
61
64
|
points,
|
|
62
65
|
featureCollection([theEllipse])
|
|
63
66
|
);
|
|
64
|
-
|
|
67
|
+
const standardDeviationalEllipseProperties = {
|
|
65
68
|
meanCenterCoordinates: getCoords(meanCenter),
|
|
66
69
|
semiMajorAxis: sigmaX,
|
|
67
70
|
semiMinorAxis: sigmaY,
|
|
@@ -69,6 +72,7 @@ function standardDeviationalEllipse(points, options) {
|
|
|
69
72
|
angle: thetaDeg,
|
|
70
73
|
percentageWithinEllipse: 100 * coordAll(pointsWithinEllipse).length / numberOfFeatures
|
|
71
74
|
};
|
|
75
|
+
theEllipse.properties = (_a = theEllipse.properties) != null ? _a : {};
|
|
72
76
|
theEllipse.properties.standardDeviationalEllipse = standardDeviationalEllipseProperties;
|
|
73
77
|
return theEllipse;
|
|
74
78
|
}
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../index.
|
|
1
|
+
{"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n FeatureCollection,\n Feature,\n Position,\n Polygon,\n GeoJsonProperties,\n Point,\n} from \"geojson\";\nimport { coordAll, featureEach } from \"@turf/meta\";\nimport { getCoords } from \"@turf/invariant\";\nimport { featureCollection, isObject, isNumber } from \"@turf/helpers\";\nimport { centerMean } from \"@turf/center-mean\";\nimport { pointsWithinPolygon } from \"@turf/points-within-polygon\";\nimport { ellipse } from \"@turf/ellipse\";\n\ndeclare interface SDEProps {\n meanCenterCoordinates: Position;\n semiMajorAxis: number;\n semiMinorAxis: number;\n numberOfFeatures: number;\n angle: number;\n percentageWithinEllipse: number;\n}\n\ndeclare interface StandardDeviationalEllipse extends Feature<Polygon> {\n properties: {\n standardDeviationalEllipse: SDEProps;\n [key: string]: any;\n } | null;\n}\n\n/**\n * Takes a collection of features and returns a standard deviational ellipse,\n * also known as a “directional distribution.” The standard deviational ellipse\n * aims to show the direction and the distribution of a dataset by drawing\n * an ellipse that contains about one standard deviation’s worth (~ 70%) of the\n * data.\n *\n * This module mirrors the functionality of {@link http://desktop.arcgis.com/en/arcmap/10.3/tools/spatial-statistics-toolbox/directional-distribution.htm|Directional Distribution}\n * in ArcGIS and the {@link http://arken.nmbu.no/~havatv/gis/qgisplugins/SDEllipse/|QGIS Standard Deviational Ellipse Plugin}\n *\n * **Bibliography**\n *\n * • Robert S. Yuill, “The Standard Deviational Ellipse; An Updated Tool for\n * Spatial Description,” _Geografiska Annaler_ 53, no. 1 (1971): 28–39,\n * doi:{@link https://doi.org/10.2307/490885|10.2307/490885}.\n *\n * • Paul Hanly Furfey, “A Note on Lefever’s “Standard Deviational Ellipse,”\n * _American Journal of Sociology_ 33, no. 1 (1927): 94—98,\n * doi:{@link https://doi.org/10.1086/214336|10.1086/214336}.\n *\n *\n * @name standardDeviationalEllipse\n * @param {FeatureCollection<Point>} points GeoJSON points\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.weight] the property name used to weight the center\n * @param {number} [options.steps=64] number of steps for the polygon\n * @param {Object} [options.properties={}] properties to pass to the resulting ellipse\n * @returns {Feature<Polygon>} an elliptical Polygon that includes approximately 1 SD of the dataset within it.\n * @example\n *\n * const bbox = [-74, 40.72, -73.98, 40.74];\n * const points = turf.randomPoint(400, {bbox: bbox});\n * const sdEllipse = turf.standardDeviationalEllipse(points);\n *\n * //addToMap\n * const addToMap = [points, sdEllipse];\n *\n */\nfunction standardDeviationalEllipse(\n points: FeatureCollection<Point>,\n options?: {\n properties?: GeoJsonProperties;\n weight?: string;\n steps?: number;\n }\n): StandardDeviationalEllipse {\n // Optional params\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n const steps = options.steps || 64;\n const weightTerm = options.weight;\n const properties = options.properties || {};\n\n // Validation:\n if (!isNumber(steps)) throw new Error(\"steps must be a number\");\n if (!isObject(properties)) throw new Error(\"properties must be a number\");\n\n // Calculate mean center & number of features:\n const numberOfFeatures = coordAll(points).length;\n const meanCenter = centerMean(points, { weight: weightTerm });\n\n // Calculate angle of rotation:\n // [X, Y] = mean center of all [x, y].\n // theta = arctan( (A + B) / C )\n // A = sum((x - X)^2) - sum((y - Y)^2)\n // B = sqrt(A^2 + 4(sum((x - X)(y - Y))^2))\n // C = 2(sum((x - X)(y - Y)))\n\n let xDeviationSquaredSum = 0;\n let yDeviationSquaredSum = 0;\n let xyDeviationSum = 0;\n\n featureEach(points, function (point) {\n // weightTerm or point.properties might be undefined, hence this check.\n const weight = weightTerm ? point.properties?.[weightTerm] || 1 : 1;\n const deviation = getDeviations(getCoords(point), getCoords(meanCenter));\n xDeviationSquaredSum += Math.pow(deviation.x, 2) * weight;\n yDeviationSquaredSum += Math.pow(deviation.y, 2) * weight;\n xyDeviationSum += deviation.x * deviation.y * weight;\n });\n\n const bigA = xDeviationSquaredSum - yDeviationSquaredSum;\n const bigB = Math.sqrt(Math.pow(bigA, 2) + 4 * Math.pow(xyDeviationSum, 2));\n const bigC = 2 * xyDeviationSum;\n const theta = Math.atan((bigA + bigB) / bigC);\n const thetaDeg = (theta * 180) / Math.PI;\n\n // Calculate axes:\n // sigmaX = sqrt((1 / n - 2) * sum((((x - X) * cos(theta)) - ((y - Y) * sin(theta)))^2))\n // sigmaY = sqrt((1 / n - 2) * sum((((x - X) * sin(theta)) - ((y - Y) * cos(theta)))^2))\n let sigmaXsum = 0;\n let sigmaYsum = 0;\n let weightsum = 0;\n featureEach(points, function (point) {\n // weightTerm or point.properties might be undefined, hence this check.\n const weight = weightTerm ? point.properties?.[weightTerm] || 1 : 1;\n const deviation = getDeviations(getCoords(point), getCoords(meanCenter));\n sigmaXsum +=\n Math.pow(\n deviation.x * Math.cos(theta) - deviation.y * Math.sin(theta),\n 2\n ) * weight;\n sigmaYsum +=\n Math.pow(\n deviation.x * Math.sin(theta) + deviation.y * Math.cos(theta),\n 2\n ) * weight;\n weightsum += weight;\n });\n\n const sigmaX = Math.sqrt((2 * sigmaXsum) / weightsum);\n const sigmaY = Math.sqrt((2 * sigmaYsum) / weightsum);\n\n const theEllipse: Feature<Polygon> = ellipse(meanCenter, sigmaX, sigmaY, {\n units: \"degrees\",\n angle: thetaDeg,\n steps: steps,\n properties: properties,\n });\n const pointsWithinEllipse = pointsWithinPolygon(\n points,\n featureCollection([theEllipse])\n );\n const standardDeviationalEllipseProperties = {\n meanCenterCoordinates: getCoords(meanCenter),\n semiMajorAxis: sigmaX,\n semiMinorAxis: sigmaY,\n numberOfFeatures: numberOfFeatures,\n angle: thetaDeg,\n percentageWithinEllipse:\n (100 * coordAll(pointsWithinEllipse).length) / numberOfFeatures,\n };\n // Make sure properties object exists.\n theEllipse.properties = theEllipse.properties ?? {};\n theEllipse.properties.standardDeviationalEllipse =\n standardDeviationalEllipseProperties;\n\n // We have added the StandardDeviationalEllipse specific properties, so\n // confirm this to Typescript with a cast.\n return theEllipse as StandardDeviationalEllipse;\n}\n\n/**\n * Get x_i - X and y_i - Y\n *\n * @private\n * @param {Position} coordinates Array of [x_i, y_i]\n * @param {Position} center Array of [X, Y]\n * @returns {Object} { x: n, y: m }\n */\nfunction getDeviations(coordinates: Position, center: Position) {\n return {\n x: coordinates[0] - center[0],\n y: coordinates[1] - center[1],\n };\n}\n\nexport { standardDeviationalEllipse, SDEProps, StandardDeviationalEllipse };\nexport default standardDeviationalEllipse;\n"],"mappings":"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","names":["_a"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/standard-deviational-ellipse",
|
|
3
|
-
"version": "7.1.0
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "turf standard-deviational-ellipse module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@turf/random": "^7.1.0
|
|
59
|
-
"@turf/truncate": "^7.1.0
|
|
58
|
+
"@turf/random": "^7.1.0",
|
|
59
|
+
"@turf/truncate": "^7.1.0",
|
|
60
60
|
"@types/benchmark": "^2.1.5",
|
|
61
61
|
"@types/tape": "^4.2.32",
|
|
62
62
|
"benchmark": "^2.1.4",
|
|
@@ -65,15 +65,18 @@
|
|
|
65
65
|
"tape": "^5.7.2",
|
|
66
66
|
"tsup": "^8.0.1",
|
|
67
67
|
"tsx": "^4.6.2",
|
|
68
|
+
"typescript": "^5.2.2",
|
|
68
69
|
"write-json-file": "^5.0.0"
|
|
69
70
|
},
|
|
70
71
|
"dependencies": {
|
|
71
|
-
"@turf/center-mean": "^7.1.0
|
|
72
|
-
"@turf/ellipse": "^7.1.0
|
|
73
|
-
"@turf/helpers": "^7.1.0
|
|
74
|
-
"@turf/invariant": "^7.1.0
|
|
75
|
-
"@turf/meta": "^7.1.0
|
|
76
|
-
"@turf/points-within-polygon": "^7.1.0
|
|
72
|
+
"@turf/center-mean": "^7.1.0",
|
|
73
|
+
"@turf/ellipse": "^7.1.0",
|
|
74
|
+
"@turf/helpers": "^7.1.0",
|
|
75
|
+
"@turf/invariant": "^7.1.0",
|
|
76
|
+
"@turf/meta": "^7.1.0",
|
|
77
|
+
"@turf/points-within-polygon": "^7.1.0",
|
|
78
|
+
"@types/geojson": "^7946.0.10",
|
|
79
|
+
"tslib": "^2.6.2"
|
|
77
80
|
},
|
|
78
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "68915eeebc9278bb40dec3f1034499698a0561ef"
|
|
79
82
|
}
|