Turf的INTERPOLATION的isobands方法可以将已知点向周围选择的点进行插值,并使用等值线将插值结果可视化。
var isobands = require('@turf/isobands');
var options = {
breaks: [0, 10, 20, 30, 40],
zProperty: 'elevation'
};
var isolines = isobands(points, field, options);
isobands接收三个参数:点集合,需要插值的字段,选项(可选)。选项包括两个属性:
为了保证精度,建议对插值点进行外插处理。
var isobands = require('@turf/isobands');
var pointGrid = require('@turf/point-grid');
var featureCollection = require('@turf/helpers').featureCollection;
//插值点
var points = featureCollection([
point([0, 0], {elevation: 2}),
point([0, 1], {elevation: 1}),
point([1, 1], {elevation: 3}),
point([1, 0], {elevation: 1.5})
]);
//插值范围格网
var cellSize = 0.1;
var bbox = [0, 0, 1, 1];
var grid = pointGrid(bbox, cellSize, {units: 'degrees'});
//插值
var field = 'elevation';
var breaks = [0, 1.2, 1.5, 1.8, 2.5, 3, 4];
var options = {breaks: breaks, zProperty: field};
var isolines = isobands(points, grid, options);
在上述示例中,isobands方法从已知点集合中提取等值线。
isobands方法的output(输出对象)包含以下属性: