2

I have a list of coordinates (lat, lon) and would like to create a grid of squares where each of these coordinates is in the center of the square using R, and preferably SF (as I am used to it), but also open for other suggestions.

I basically trying to construct a grid of squares (that touches each other) around the points in the attached map.

This is first 5 obs of my data (the entire dataset spread across all Africa - like in the attached picture in the link):

Bounding box:  xmin: 18.25 ymin: -34.75 xmax: 20.25 ymax: -34.25
Geodetic CRS:  WGS 84
   cell             geometry
1     1 POINT (19.75 -34.75)
15    2 POINT (20.25 -34.75)
29    3 POINT (18.25 -34.25)
43    4 POINT (18.75 -34.25)
57    5 POINT (19.25 -34.25)
71    6 POINT (19.75 -34.25)

and would like to make a grid style st_make_grid(cellsize = XXX, what = "polygons") where the geometris points above are in the center of each polygon.

enter image description here

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294
Guy Pincus
  • 37
  • 2
  • 2
    This would be a much better question if you provided a small amount of sample data to illustrate. For illustration purposes a 2x2 or a 3x3 grid is probably sufficient. – Gregor Thomas Nov 17 '21 at 21:08
  • Thank you for your comment, I updated my post! Hope it is clear now. – Guy Pincus Nov 18 '21 at 14:30
  • Is it guaranteed that your points are evenly spaced? Is the map you included a map of the points, or of what you're trying to obtain? If you just want to use your points as grid centers, try `st_make_grid(x, what = "centers")` – camille Dec 17 '21 at 17:50
  • Does this answer your question? [Create grid around points (centroids) using sf](https://stackoverflow.com/questions/58800327/create-grid-around-points-centroids-using-sf) – rafa.pereira Dec 06 '22 at 14:35

0 Answers0