Initial problem: I am currently trying to create a spatial grid in which each cell is centered on predefined spatial points. These spatial points are projected in the WGS84 international coordinate system.
I am starting with a long/lat dataframe containing around 8000 point-location over France (data available here).
df=read.table("~/centroids.csv",sep=",",header=T)
plot(df$longitude,df$latitude,pch=".")
I want to compute "tile" polygons that will fill the entire space around these points. Something like in this post, with each point of df at the center of tiles, such as :
I tried several methods from the sf and raster package such as : st_make_grid(), rasterFromXYZ() combined with rasterToPolygons() that I saw in this post, or even the basic raster() using gridded() that I saw on this post. I also tried to use gBuffer() such as in this post. But without any sucess... I am always fighting against projection or non-regular/planar coordinates errors !
Once I will be able compute those tiles (or polygons), I want to store them in a simple feature object (from the sf package). Within this sf object: each polygon will correspond to a cell of the final spatial grid; each polygon will be centered on a spatial point from df; and each polygon will inherit the ID of the point (from df) on which it is centered.
Is that possible ???