hexGrid
描述
🌐 Description
接受一个边界框和单元的直径,并返回一个由平顶六边形或三角形(Polygon 特性)组成的 FeatureCollection,这些多边形排列在如 Hexagonal Grids 所描述的“奇-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? | Object | 可选参数 (默认 {}) |
| options.units? | Units | 用于计算单元格大小。支持所有有效的 Turf 单位。(默认 '公里') |
| options.properties? | Object | 传递到网格的每个六边形或三角形 (默认 {}) |
| options.mask? | Feature<Polygon | MultiPolygon> | 如果传入的是多边形或多多边形,网格点将只在其内部创建 |
| options.triangles? | boolean | 是否以三角形而不是六边形返回 (默认 false) |
返回
🌐 Returns
FeatureCollection<Polygon> 六边形网格
示例
🌐 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(...);