hexGrid
描述
¥Description
获取一个边界框和像元的直径,并返回一个由平顶六边形或三角形(多边形 特性)组成的 FeatureCollection,这些六边形或三角形按照 六边形网格 中的描述排列在 "odd-q" 垂直网格中。
¥Takes a bounding box and the diameter of the cell and returns a FeatureCollection of flat-topped hexagons or triangles (Polygon features) aligned in an "odd-q" vertical grid as described in Hexagonal Grids.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
bbox | BBox | 按 [minX, minY, maxX, maxY] 顺序排列的范围 |
cellSide | number | 六边形或三角形边的长度(以单位表示)。它也与六边形外接圆的半径重合。 |
options? | 对象 | 可选参数(默认 {}) |
options.units? | string | 用于计算像元大小,可以是度、弧度、英里或公里(默认 'kilometers') |
options.properties? | 对象 | 传递给网格的每个六边形或三角形(默认 {}) |
options.mask? | 特性<多边形> | 如果传递的是多边形或多多边形,则网格点将仅在其内部创建。 |
options.triangles? | boolean | 是否返回三角形而不是六边形(默认 false) |
返回
¥Returns
FeatureCollection<多边形> 六边形网格
¥FeatureCollection<Polygon> a hexagonal grid
示例
¥Examples
var bbox = [-96, 31, -84, 40];
var cellSide = 50;
var options = { units: "miles" };
var hexgrid = turf.hexGrid(bbox, cellSide, options);
安装
¥Installation
$ npm install @turf/hex-grid
import { hexGrid } from "@turf/hex-grid";
const result = hexGrid(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.hexGrid(...);