Skip to main content
Version: Next

interpolate

Description

Takes a set of points and estimates their 'property' values on a grid using the Inverse Distance Weighting (IDW) method.

Parameters

NameTypeDescription
pointsFeatureCollection<Point>with known value
cellSizenumberthe distance across each grid point
options?ObjectOptional parameters (default {})
options.gridType?stringdefines the output format based on a Grid Type (options: 'square' | 'point' | 'hex' | 'triangle') (default 'square')
options.property?stringthe property name in points from which z-values will be pulled, zValue fallbacks to 3rd coordinate if no property exists. (default 'elevation')
options.units?Unitsused in calculating cellSize. Supports all valid Turf Units. (default 'kilometers')
options.weight?numberexponent regulating the distance-decay weighting (default 1)
options.bbox?BBoxBounding Box Array [west, south, east, north] associated with the FeatureCollection. (default bbox(points))

Returns

FeatureCollection<Point | Polygon> grid of points or polygons with interpolated 'property'

Examples

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);

Installation

$ npm install @turf/interpolate

import { interpolate } from "@turf/interpolate";
const result = interpolate(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.interpolate(...);