@turf/interpolate 6.4.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 +11 -10
- package/dist/es/index.js +0 -0
- package/dist/js/index.js +28 -18
- package/index.d.ts +2 -1
- package/package.json +16 -15
package/README.md
CHANGED
|
@@ -6,17 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
Takes a set of points and estimates their 'property' values on a grid using the [Inverse Distance Weighting (IDW) method][1].
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### Parameters
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- `options.gridType` **[string][6]** defines the output format based on a Grid Type (options: 'square' | 'point' | 'hex' | 'triangle') (optional, default `'square'`)
|
|
15
|
-
- `options.property` **[string][6]** the property name in `points` from which z-values will be pulled, zValue fallbacks to 3rd coordinate if no property exists. (optional, default `'elevation'`)
|
|
16
|
-
- `options.units` **[string][6]** used in calculating cellSize, can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
|
|
17
|
-
- `options.weight` **[number][4]** exponent regulating the distance-decay weighting (optional, default `1`)
|
|
11
|
+
* `points` **[FeatureCollection][2]<[Point][3]>** with known value
|
|
12
|
+
* `cellSize` **[number][4]** the distance across each grid point
|
|
13
|
+
* `options` **[Object][5]** Optional parameters (optional, default `{}`)
|
|
18
14
|
|
|
19
|
-
**
|
|
15
|
+
* `options.gridType` **[string][6]** defines the output format based on a Grid Type (options: 'square' | 'point' | 'hex' | 'triangle') (optional, default `'square'`)
|
|
16
|
+
* `options.property` **[string][6]** the property name in `points` from which z-values will be pulled, zValue fallbacks to 3rd coordinate if no property exists. (optional, default `'elevation'`)
|
|
17
|
+
* `options.units` **[string][6]** used in calculating cellSize, can be degrees, radians, miles, or kilometers (optional, default `'kilometers'`)
|
|
18
|
+
* `options.weight` **[number][4]** exponent regulating the distance-decay weighting (optional, default `1`)
|
|
19
|
+
|
|
20
|
+
### Examples
|
|
20
21
|
|
|
21
22
|
```javascript
|
|
22
23
|
var points = turf.randomPoint(30, {bbox: [50, 30, 70, 50]});
|
|
@@ -32,7 +33,7 @@ var grid = turf.interpolate(points, 100, options);
|
|
|
32
33
|
var addToMap = [grid];
|
|
33
34
|
```
|
|
34
35
|
|
|
35
|
-
Returns **[FeatureCollection][2]
|
|
36
|
+
Returns **[FeatureCollection][2]<([Point][3] | [Polygon][7])>** grid of points or polygons with interpolated 'property'
|
|
36
37
|
|
|
37
38
|
[1]: https://en.wikipedia.org/wiki/Inverse_distance_weighting
|
|
38
39
|
|
package/dist/es/index.js
CHANGED
|
File without changes
|
package/dist/js/index.js
CHANGED
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var triangleGrid = _interopDefault(require('@turf/triangle-grid'));
|
|
12
|
-
var clone = _interopDefault(require('@turf/clone'));
|
|
3
|
+
var bbox = require('@turf/bbox');
|
|
4
|
+
var hexGrid = require('@turf/hex-grid');
|
|
5
|
+
var pointGrid = require('@turf/point-grid');
|
|
6
|
+
var distance = require('@turf/distance');
|
|
7
|
+
var centroid = require('@turf/centroid');
|
|
8
|
+
var squareGrid = require('@turf/square-grid');
|
|
9
|
+
var triangleGrid = require('@turf/triangle-grid');
|
|
10
|
+
var clone = require('@turf/clone');
|
|
13
11
|
var helpers = require('@turf/helpers');
|
|
14
12
|
var meta = require('@turf/meta');
|
|
15
13
|
var invariant = require('@turf/invariant');
|
|
16
14
|
|
|
15
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
|
+
|
|
17
|
+
var bbox__default = /*#__PURE__*/_interopDefaultLegacy(bbox);
|
|
18
|
+
var hexGrid__default = /*#__PURE__*/_interopDefaultLegacy(hexGrid);
|
|
19
|
+
var pointGrid__default = /*#__PURE__*/_interopDefaultLegacy(pointGrid);
|
|
20
|
+
var distance__default = /*#__PURE__*/_interopDefaultLegacy(distance);
|
|
21
|
+
var centroid__default = /*#__PURE__*/_interopDefaultLegacy(centroid);
|
|
22
|
+
var squareGrid__default = /*#__PURE__*/_interopDefaultLegacy(squareGrid);
|
|
23
|
+
var triangleGrid__default = /*#__PURE__*/_interopDefaultLegacy(triangleGrid);
|
|
24
|
+
var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
|
|
25
|
+
|
|
17
26
|
/**
|
|
18
27
|
* Takes a set of points and estimates their 'property' values on a grid using the [Inverse Distance Weighting (IDW) method](https://en.wikipedia.org/wiki/Inverse_distance_weighting).
|
|
19
28
|
*
|
|
@@ -59,24 +68,24 @@ function interpolate(points, cellSize, options) {
|
|
|
59
68
|
gridType = gridType || "square";
|
|
60
69
|
weight = weight || 1;
|
|
61
70
|
|
|
62
|
-
var box =
|
|
71
|
+
var box = bbox__default['default'](points);
|
|
63
72
|
var grid;
|
|
64
73
|
switch (gridType) {
|
|
65
74
|
case "point":
|
|
66
75
|
case "points":
|
|
67
|
-
grid =
|
|
76
|
+
grid = pointGrid__default['default'](box, cellSize, options);
|
|
68
77
|
break;
|
|
69
78
|
case "square":
|
|
70
79
|
case "squares":
|
|
71
|
-
grid =
|
|
80
|
+
grid = squareGrid__default['default'](box, cellSize, options);
|
|
72
81
|
break;
|
|
73
82
|
case "hex":
|
|
74
83
|
case "hexes":
|
|
75
|
-
grid =
|
|
84
|
+
grid = hexGrid__default['default'](box, cellSize, options);
|
|
76
85
|
break;
|
|
77
86
|
case "triangle":
|
|
78
87
|
case "triangles":
|
|
79
|
-
grid =
|
|
88
|
+
grid = triangleGrid__default['default'](box, cellSize, options);
|
|
80
89
|
break;
|
|
81
90
|
default:
|
|
82
91
|
throw new Error("invalid gridType");
|
|
@@ -88,8 +97,8 @@ function interpolate(points, cellSize, options) {
|
|
|
88
97
|
// calculate the distance from each input point to the grid points
|
|
89
98
|
meta.featureEach(points, function (point) {
|
|
90
99
|
var gridPoint =
|
|
91
|
-
gridType === "point" ? gridFeature :
|
|
92
|
-
var d =
|
|
100
|
+
gridType === "point" ? gridFeature : centroid__default['default'](gridFeature);
|
|
101
|
+
var d = distance__default['default'](gridPoint, point, options);
|
|
93
102
|
var zValue;
|
|
94
103
|
// property has priority for zValue, fallbacks to 3rd coordinate from geometry
|
|
95
104
|
if (property !== undefined) zValue = point.properties[property];
|
|
@@ -101,7 +110,7 @@ function interpolate(points, cellSize, options) {
|
|
|
101
110
|
zw += w * zValue;
|
|
102
111
|
});
|
|
103
112
|
// write interpolated value for each grid point
|
|
104
|
-
var newFeature =
|
|
113
|
+
var newFeature = clone__default['default'](gridFeature);
|
|
105
114
|
newFeature.properties[property] = zw / sw;
|
|
106
115
|
results.push(newFeature);
|
|
107
116
|
});
|
|
@@ -109,3 +118,4 @@ function interpolate(points, cellSize, options) {
|
|
|
109
118
|
}
|
|
110
119
|
|
|
111
120
|
module.exports = interpolate;
|
|
121
|
+
module.exports.default = interpolate;
|
package/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turf/interpolate",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.0",
|
|
4
4
|
"description": "turf interpolate module",
|
|
5
5
|
"author": "Turf Authors",
|
|
6
6
|
"contributors": [
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git://github.com/Turfjs/turf.git"
|
|
17
17
|
},
|
|
18
|
+
"funding": "https://opencollective.com/turf",
|
|
18
19
|
"publishConfig": {
|
|
19
20
|
"access": "public"
|
|
20
21
|
},
|
|
@@ -44,10 +45,10 @@
|
|
|
44
45
|
"docs": "node ../../scripts/generate-readmes",
|
|
45
46
|
"test": "npm-run-all test:*",
|
|
46
47
|
"test:tape": "node -r esm test.js",
|
|
47
|
-
"test:types": "tsc --esModuleInterop --noEmit types.ts"
|
|
48
|
+
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
|
|
48
49
|
},
|
|
49
50
|
"devDependencies": {
|
|
50
|
-
"@turf/truncate": "^
|
|
51
|
+
"@turf/truncate": "^7.0.0-alpha.0",
|
|
51
52
|
"benchmark": "*",
|
|
52
53
|
"chromatism": "*",
|
|
53
54
|
"load-json-file": "*",
|
|
@@ -57,17 +58,17 @@
|
|
|
57
58
|
"write-json-file": "*"
|
|
58
59
|
},
|
|
59
60
|
"dependencies": {
|
|
60
|
-
"@turf/bbox": "^
|
|
61
|
-
"@turf/centroid": "^
|
|
62
|
-
"@turf/clone": "^
|
|
63
|
-
"@turf/distance": "^
|
|
64
|
-
"@turf/helpers": "^
|
|
65
|
-
"@turf/hex-grid": "^
|
|
66
|
-
"@turf/invariant": "^
|
|
67
|
-
"@turf/meta": "^
|
|
68
|
-
"@turf/point-grid": "^
|
|
69
|
-
"@turf/square-grid": "^
|
|
70
|
-
"@turf/triangle-grid": "^
|
|
61
|
+
"@turf/bbox": "^7.0.0-alpha.0",
|
|
62
|
+
"@turf/centroid": "^7.0.0-alpha.0",
|
|
63
|
+
"@turf/clone": "^7.0.0-alpha.0",
|
|
64
|
+
"@turf/distance": "^7.0.0-alpha.0",
|
|
65
|
+
"@turf/helpers": "^7.0.0-alpha.0",
|
|
66
|
+
"@turf/hex-grid": "^7.0.0-alpha.0",
|
|
67
|
+
"@turf/invariant": "^7.0.0-alpha.0",
|
|
68
|
+
"@turf/meta": "^7.0.0-alpha.0",
|
|
69
|
+
"@turf/point-grid": "^7.0.0-alpha.0",
|
|
70
|
+
"@turf/square-grid": "^7.0.0-alpha.0",
|
|
71
|
+
"@turf/triangle-grid": "^7.0.0-alpha.0"
|
|
71
72
|
},
|
|
72
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
|
|
73
74
|
}
|