Creates an interpolated grid of points using the Inverse Distance Weighting method.
npm install @turf/interpolateTakes a set of points and estimates their 'property' values on a grid using the [Inverse Distance Weighting (IDW) method][1].
* points [FeatureCollection][2]<[Point][3]> with known value
* cellSize [number][4] the distance across each grid point
* options [Object][5] Optional parameters (optional, default {})
* options.gridType [string][6] defines the output format based on a Grid Type (options: 'square' | 'point' | 'hex' | 'triangle') (optional, default 'square')
* 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')
* options.units Units used in calculating cellSize. Supports all valid Turf [Units][7]. (optional, default 'kilometers')
* options.weight [number][4] exponent regulating the distance-decay weighting (optional, default 1)
* options.bbox [BBox][8] Bounding Box Array \[west, south, east, north] associated with the FeatureCollection. (optional, default bbox(points))
``javascript
var points = turf.randomPoint(30, {bbox: [50, 30, 70, 50]});
// add a random property to each point
turf.featureEach(points, function(point) {
point.properties.solRad = Math.random() * 50;
});
var options = {gridType: 'points', property: 'solRad', units: 'miles'};
var grid = turf.interpolate(points, 100, options);
//addToMap
var addToMap = [grid];
`
Returns [FeatureCollection][2]<([Point][3] | [Polygon][9])> grid of points or polygons with interpolated 'property'
[1]: https://en.wikipedia.org/wiki/Inverse_distance_weighting
[2]: https://tools.ietf.org/html/rfc7946#section-3.3
[3]: https://tools.ietf.org/html/rfc7946#section-3.1.2
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[7]: https://turfjs.org/docs/api/types/Units
[8]: https://tools.ietf.org/html/rfc7946#section-5
[9]: https://tools.ietf.org/html/rfc7946#section-3.1.6
---
This module is part of the Turfjs project, an open source module collection dedicated to geographic algorithms. It is maintained in the Turfjs/turf repository, where you can create PRs and issues.
Install this single module individually:
`sh`
$ npm install @turf/interpolate
Or install the all-encompassing @turf/turf module that includes all modules as functions:
`sh``
$ npm install @turf/turf