My knowledge of R is still pretty simple, and I need help. I am trying to create a grid over the area of study. I would like the grid cells to be centered on the sample points that I generated on a spatial polygon with a function spsample. Here is my code:
library(sp)
xym <- matrix(c(-95000, 90000, 90000, -95000, 443100, 443100, 590000, 590000), nrow = 4, ncol = 2)
p <- Polygon(xym)
ps <- Polygons(list(p), 1)
sps <- SpatialPolygons(list(ps))
proj4string(sps) <- CRS("+init=epsg:32198")
data <- data.frame(f = 99.9)
spdf <- SpatialPolygonsDataFrame(sps, data)
spdf
library(raster)
ptsreg <- spsample(spdf, 1000, type = "regular")
plot(spdf, col = "azure2")
points(ptsreg, pch = 16, col = "black")
I would like these points to be the centroids of the mesh cells. I know that I could create square polygons from single central coordinates (see Create square polygons from single-center coordinates and an area in R ). I'm not sure that I have the coordinates of the points that I created, though ...
SpatialPolygonsDataFrame ( ), - (, !):

! !