Files
2026-04-09 13:19:47 -05:00

33 lines
1.5 KiB
TypeScript
Executable File

import { BBox, Feature, FeatureCollection, MultiPolygon, Polygon, Properties, Units } from "@turf/helpers";
/**
* Creates a grid of rectangles from a bounding box, {@link Feature} or {@link FeatureCollection}.
*
* @name rectangleGrid
* @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
* @param {number} cellWidth of each cell, in units
* @param {number} cellHeight of each cell, in units
* @param {Object} [options={}] Optional parameters
* @param {string} [options.units='kilometers'] units ("degrees", "radians", "miles", "kilometers") that the given cellWidth
* and cellHeight are expressed in. Converted at the southern border.
* @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,
* the grid Points will be created only inside it
* @param {Object} [options.properties={}] passed to each point of the grid
* @returns {FeatureCollection<Polygon>} a grid of polygons
* @example
* var bbox = [-95, 30 ,-85, 40];
* var cellWidth = 50;
* var cellHeight = 20;
* var options = {units: 'miles'};
*
* var rectangleGrid = turf.rectangleGrid(bbox, cellWidth, cellHeight, options);
*
* //addToMap
* var addToMap = [rectangleGrid]
*/
declare function rectangleGrid<P = Properties>(bbox: BBox, cellWidth: number, cellHeight: number, options?: {
units?: Units;
properties?: P;
mask?: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon;
}): FeatureCollection<Polygon, P>;
export default rectangleGrid;