I am trying to recreate a map in R. I need 2 by 5 degree grid cells across the contiguous United States, but plotted in Albers Equal Area. The result is a grid with curved lines and slightly variable grid size, so I assume I cannot use a raster. I am able to reproduce the points, but not the grid. How do I make grid (polygon) lines for these points?
library(raster) e <- as(raster::extent(-125, -65, 25, 49), "SpatialPolygons") grd_lrg <- as.data.frame(makegrid(e, "regular", cellsize = c(5,2))) names(grd_lrg) <- c("X", "Y") coordinates(grd_lrg) <- c("X", "Y") # add projection information to the empty grid proj4string(grd_lrg) <- CRS("+init=epsg:4326") # transform to equal area Albers USGS grd_lrg <- spTransform(grd_lrg, CRS("+init=epsg:5070")) # plot it plot(grd_lrg)
So I am thinking I need to convert the points to Albers first and then add the lines?