index.d.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. import { BBox, Feature, FeatureCollection, MultiPolygon, Polygon, Properties, Units } from "@turf/helpers";
  2. /**
  3. * Creates a grid of rectangles from a bounding box, {@link Feature} or {@link FeatureCollection}.
  4. *
  5. * @name rectangleGrid
  6. * @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
  7. * @param {number} cellWidth of each cell, in units
  8. * @param {number} cellHeight of each cell, in units
  9. * @param {Object} [options={}] Optional parameters
  10. * @param {string} [options.units='kilometers'] units ("degrees", "radians", "miles", "kilometers") that the given cellWidth
  11. * and cellHeight are expressed in. Converted at the southern border.
  12. * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,
  13. * the grid Points will be created only inside it
  14. * @param {Object} [options.properties={}] passed to each point of the grid
  15. * @returns {FeatureCollection<Polygon>} a grid of polygons
  16. * @example
  17. * var bbox = [-95, 30 ,-85, 40];
  18. * var cellWidth = 50;
  19. * var cellHeight = 20;
  20. * var options = {units: 'miles'};
  21. *
  22. * var rectangleGrid = turf.rectangleGrid(bbox, cellWidth, cellHeight, options);
  23. *
  24. * //addToMap
  25. * var addToMap = [rectangleGrid]
  26. */
  27. declare function rectangleGrid<P = Properties>(bbox: BBox, cellWidth: number, cellHeight: number, options?: {
  28. units?: Units;
  29. properties?: P;
  30. mask?: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon;
  31. }): FeatureCollection<Polygon, P>;
  32. export default rectangleGrid;