Create spatial polygon grid from spatial points in R

here is a solution using sf and sf::st_make_grid:

library(raster)
library(sf)

e <- as(raster::extent(-125, -65, 25, 49), "SpatialPolygons") %>% 
  st_as_sf()

grd_lrg <- st_make_grid(e, cellsize = c(5, 2)) %>%
  st_set_crs(4326) %>% 
  st_transform(5070)

plot(grd_lrg)

enter image description here


You can make a long/lat raster and transform

library(raster)
r <- raster(ext = extent(-125, -65, 25, 49), res=c(5,2))
values(r) <- 1:ncell(r)
rA <- projectRaster(r, crs="+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m")

But what you want seems to be

library(rgdal)
p <- rasterToPolygons(r) 
# or do:  p <- as(r, "SpatialPolygonsDataFrame")
pA <- spTransform(p, "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +datum=NAD83 +units=m")


plot(rA, axes=FALSE, box=FALSE)
plot(pA, add=TRUE)

enter image description here