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 | 数字 | 六边形或三角形边的长度,单位为单位。它也将与六边形外接圆的半径一致。 |
| options? | 对象 | 可选参数 (默认 {}) |
| options.units? | 单位 | 用于计算单元格大小。支持所有有效的 Turf 单位。(默认 'kilometers') |
| options.properties? | 对象 | 传递给网格的每个六边形或三角形 (默认值 {}) |
| options.mask? | 特性<多边形 | 多多边形> | 如果传入的是多边形或多多边形,则网格点只会在其内部创建 |
| options.triangles? | 布尔 | 是否以三角形而不是六边形返回 (默认 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(...);