interpolation
interpolate
npm install @turf/interpolate
接收一组点要素集,通过传入的 properties 参数使用反距离加权法(IDW)估算要素集并返回
参数
| 入参 | 类型 | 描述 | 
|---|---|---|
| points | FeatureCollection<Point> | 传入的要素集 | 
| cellSize | Number | 每个网格点之间的距离 | 
| options | Object | 可配置项 | 
options
| 属性 | 类型 | 默认值 | 描述 | 
|---|---|---|---|
| gridType | String | “square” | 出参要素集的要素类型,可选值有:”square”(矩形)、”point”(点)、”hex”(六边形)、”triangle”(三角形) | 
| property | String | “elevation” | 参与计算的属性 | 
| units | String | “kilometers” | 单位,可选的有 degrees、radians、miles、kilometers | 
| weight | Number | 1 | 调节距离衰减权重的指数 | 
返回
FeatureCollection<Point|Polygon>
范例
var points = turf.randomPoint(30, { bbox: [50, 30, 70, 50] });// add a random property to each pointturf.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);
isobands
npm install @turf/isobands
接收点要素集,根据参与分级的属性和分级的数组计算出等值面并返回
值得注意的是,该方法可能还未实现
参数
| 入参 | 类型 | 描述 | 
|---|---|---|
| pointGrid | FeatureCollection<Point> | 传入的要素集 | 
| breaks | Array | 分级的数组 | 
| options | Object | 可配置项 | 
options
| 属性 | 类型 | 默认值 | 描述 | 
|---|---|---|---|
| zProperty | String | “elevation” | 参与分级的属性 | 
| commonProperties | Object | {} | 每个要素的属性 | 
| breaksProperties | Array | [] | 
返回
isolines
npm install @turf/isolines
接收点要素集,根据参与分级的属性和分级的数组计算出等值线并返回
参数
| 入参 | 类型 | 描述 | 
|---|---|---|
| points | FeatureCollection<Point> | 传入的要素集 | 
| breaks | Array | 分级的数组 | 
| options | Object | 可配置项 | 
options
| 属性 | 类型 | 默认值 | 描述 | 
|---|---|---|---|
| zProperty | String | “elevation” | 参与分级的属性 | 
| commonProperties | Object | {} | 每个要素的属性 | 
| breaksProperties | Array | [] | 
返回
FeatureCollection<MultiLineString>
范例
// create a grid of points with random z-values in their propertiesvar extent = [0, 30, 20, 50];var cellWidth = 100;var pointGrid = turf.pointGrid(extent, cellWidth, { units: "miles" });for (var i = 0; i < pointGrid.features.length; i++) {pointGrid.features[i].properties.temperature = Math.random() * 10;}var breaks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; // 生成10个type为MutiLineString的要素,范围分别是 0-1、1-2 以此类推var lines = turf.isolines(pointGrid, breaks, { zProperty: "temperature" });
planepoint
npm install @turf/planepoint
接收一个 type 为 Polygon三角形平面要素,并在该要素内获取一个点要素,计算并返回该点的 z 值。面要素应该包含a,b,c三个属性值
值得注意的是,z 值即标准分数
参数
| 入参 | 类型 | 描述 | 
|---|---|---|
| point | Coord | 需要被计算 z 值的点 | 
| triangle | Feature<Polygon> | 三角形平面要素 | 
返回
Number - z 值数值
范例
var point = turf.point([-75.3221, 39.529]);// "a", "b", and "c" values represent the values of the coordinates in order.var triangle = turf.polygon([[[-75.1221, 39.57],[-75.58, 39.18],[-75.97, 39.86],[-75.1221, 39.57]]],{a: 11,b: 122,c: 44});var zValue = turf.planepoint(point, triangle); // 37.43364475092331point.properties.zValue = zValue;
tin
npm install @turf/tin
接收一组点要素集合,创建该集合的 TIN(Triangulated Irregular Network,不规则三角形格网)并返回
参数
| 入参 | 类型 | 描述 | 
|---|---|---|
| points | FeatureCollection<Point> | 三角形平面要素 | 
| z | String | 可选,如果未给定则不会向出参的面要素添加 properties | 
返回
范例
// generate some random point datavar points = turf.randomPoint(30, { bbox: [50, 30, 70, 50] });// add a random property to each point between 0 and 9for (var i = 0; i < points.features.length; i++) {points.features[i].properties.z = ~~(Math.random() * 9);}var tin = turf.tin(points, "z");
