interpolate
描述
🌐 Description
获取一组点,并使用反距离加权(IDW)方法在网格上估计它们的“属性”值。
🌐 Takes a set of points and estimates their 'property' values on a grid using the Inverse Distance Weighting (IDW) method.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| 点 | FeatureCollection<点> | 已知值 |
| cellSize | 数字 | 每个网格点之间的距离 |
| options? | 对象 | 可选参数 (默认 {}) |
| options.gridType? | 字符串 | 根据网格类型定义输出格式(选项:'square' | 'point' | 'hex' | 'triangle')(默认 'square') |
| options.property? | 字符串 | 从 points 中提取 z 值的属性名称,如果没有该属性,则 z 值回退到第 3 个坐标。(默认 'elevation') |
| options.units? | 单位 | 用于计算 cellSize。支持所有有效的 Turf 单位。(默认 'kilometers') |
| options.weight? | 数字 | 调节距离衰减权重的指数 (默认 1) |
| options.bbox? | BBox | 与 FeatureCollection 关联的边界框数组 [西, 南, 东, 北]。( 默认 bbox(points)) |
返回
🌐 Returns
FeatureCollection<Point | Polygon> 具有插值“属性”的点或多边形网格
示例
🌐 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(...);