I'm trying to generate an evenly spaced grid of coordinates inside a polygon. I know that I can generate random points like follows:
const polygon = L.polygon([somePoints]).addTo(map); const bounds = polygon.getBounds(); const y_max = bounds.getSouth(); const y_min = bounds.getNorth(); const x_max = bounds.getEast(); const x_min = bounds.getWest(); const lat = y_min + (Math.random() * (y_max - y_min)); const lng = x_min + (Math.random() * (x_max - x_min)); const coordinate = turf.point([lat, lng]);
What I'm struggling with is preventing random clusters of points. Are there any guards I can place to make the generated coordinates evenly spaced (or as close to that as possible)?