rectangleGrid
描述
🌐 Description
创建矩形多边形网格,其宽度和高度以度为单位。
🌐 Creates a grid of rectangular polygons with width and height consistent in degrees
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| bbox | BBox | 网格的范围按照 [minX, minY, maxX, maxY] 顺序。如果网格不能完全填充边界框,则它会居中。 |
| cellWidth | number | 每个单元格的宽度,单位 |
| cellHeight | number | 每个单元格的高度,单位 |
| options? | Object | 可选参数 (默认 {}) |
| options.units? | Units | 单元格宽度和高度值的单位。支持所有有效的 Turf 单位。如果你正在寻找线性单位(例如公里)下宽度和高度相等的矩形,那么这个模块不适合你。cellWidth 和 cellHeight 会从提供的单位内部转换为度数,因此生成的多边形的宽度和高度仅在度数上保持一致。(默认 '公里') |
| options.mask? | Feature<Polygon | MultiPolygon> | 如果传入的是多边形或多多边形,网格点将只在其内部创建 |
| options.properties? | Object | 传递到网格的每个点 (默认 {}) |
返回
🌐 Returns
FeatureCollection<Polygon> 多边形网格
示例
🌐 Examples
var bbox = [-95, 30, -85, 40];
var cellWidth = 50;
var cellHeight = 20;
var options = { units: "miles" };
var rectangleGrid = turf.rectangleGrid(bbox, cellWidth, cellHeight, options);
安装
🌐 Installation
$ npm install @turf/rectangle-grid
import { rectangleGrid } from "@turf/rectangle-grid";
const result = rectangleGrid(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.rectangleGrid(...);