@turf/interpolate
interpolate
Takes a set of points and estimates their 'property' values on a grid using the Inverse Distance Weighting (IDW) method.
Parameters
points
FeatureCollection<Point> with known valuecellSize
number the distance across each grid pointgridType
[string] defines the output format based on a Grid Type (options: 'square' | 'point' | 'hex' | 'triangle') (optional, default 'square'
)property
[string] the property name in points
from which z-values will be pulled, zValue fallbacks to 3rd coordinate if no property exists. (optional, default 'elevation'
)units
[string] used in calculating cellSize, can be degrees, radians, miles, or kilometers (optional, default kilometers
)weight
[number] exponent regulating the distance-decay weighting (optional, default 1
)
Examples
var points = turf.random('points', 30, {
bbox: [50, 30, 70, 50]
});
turf.featureEach(points, function(point) {
point.properties.solRad = Math.random() * 50;
});
var grid = turf.interpolate(points, 100, 'points', 'solRad', 'miles');
var addToMap = [grid];
Returns FeatureCollection<(Point | Polygon)> grid of points or polygons with interpolated 'property'
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.
Installation
Install this module individually:
$ npm install @turf/interpolate
Or install the Turf module that includes it as a function:
$ npm install @turf/turf