index.js 1.1 KB

12345678910111213141516171819202122232425262728
  1. import rectangleGrid from "@turf/rectangle-grid";
  2. /**
  3. * Creates a square grid from a bounding box.
  4. *
  5. * @name squareGrid
  6. * @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
  7. * @param {number} cellSide of each cell, in units
  8. * @param {Object} [options={}] Optional parameters
  9. * @param {string} [options.units='kilometers'] used in calculating cellSide, can be degrees,
  10. * radians, miles, or kilometers
  11. * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,
  12. * the grid Points will be created only inside it
  13. * @param {Object} [options.properties={}] passed to each point of the grid
  14. * @returns {FeatureCollection<Polygon>} grid a grid of polygons
  15. * @example
  16. * var bbox = [-95, 30 ,-85, 40];
  17. * var cellSide = 50;
  18. * var options = {units: 'miles'};
  19. *
  20. * var squareGrid = turf.squareGrid(bbox, cellSide, options);
  21. *
  22. * //addToMap
  23. * var addToMap = [squareGrid]
  24. */
  25. export default function squareGrid(bbox, cellSide, options) {
  26. if (options === void 0) { options = {}; }
  27. return rectangleGrid(bbox, cellSide, cellSide, options);
  28. }