interpolate
描述
¥Description
获取一组点,并使用 反距离加权 (IDW) 方法 估计它们在网格上的 'property' 值。
¥Takes a set of points and estimates their 'property' values on a grid using the Inverse Distance Weighting (IDW) method.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
points | FeatureCollection<点> | 已知值 |
cellSize | number | 每个网格点的距离 |
options? | 对象 | 可选参数(默认 {}) |
options.gridType? | string | 根据网格类型定义输出格式(选项:'square' | 'point' | 'hex' | 'triangle')(默认 'square') |
options.property? | string | points 中用于提取 z 值的属性名称,如果不存在属性,则 z 值回退到第三个坐标。(默认 'elevation') |
options.units? | string | 用于计算像元大小,可以是度、弧度、英里或公里(默认 'kilometers') |
options.weight? | number | 用于控制距离衰减权重的指数(默认 1) |
options.bbox? | BBox | 与 FeatureCollection 关联的边界框数组 [西、南、东、北]。(默认 bbox(points)) |
返回
¥Returns
FeatureCollection<点 | 多边形> 带插值 'property' 的点或多边形网格
¥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(...);