描述
接收一组点,使用 Inverse Distance Weighting (IDW) method 估计网格上它们的'属性'值。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| points | FeatureCollection<Point> | 已知值的点 |
| cellSize | number | 每个网格点的距离 |
| options? | Object | 可选参数 (默认 {}) |
| options.gridType? | string | 基于网格类型定义输出格式(选项:'square' | 'point' | 'hex' | 'triangle') (默认 'square') |
| options.property? | string | points 中从中获取 z 值的属性名称,如果不存在属性则回退到第 3 个坐标。 (default 'elevation') |
| options.units? | Units | 用于计算 cellSize。支持所有有效的 Turf Units。 (默认 'kilometers') |
| options.weight? | number | 调节距离衰减加权的指数 (默认 1) |
| options.bbox? | BBox | 与 FeatureCollection 关联的边界框数组。 (默认 bbox(points)) |
返回值
FeatureCollection<Point | Polygon> 具有插值'属性'的点或多边形网格
示例
javascript
var points = turf.randomPoint(30, { bbox: [50, 30, 70, 50] });
// 为每个点添加随机属性
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);安装
javascript
$ npm install @turf/interpolate
import { interpolate } from "@turf/interpolate";
const result = interpolate(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.interpolate(...);