# create a new (not projected) RasterLayer with cellnumbers as values
r <- raster(xmn=-110, xmx=-90, ymn=40, ymx=60, ncols=40, nrows=40, crs="+proj=longlat")
r <- setValues(r, 1:ncell(r))
projection(r)
# proj.4 projection description
newproj <- "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100 +datum=WGS84"
#simplest approach
pr1 <- projectRaster(r, crs=newproj)
# alternatively also set the resolution
pr2 <- projectRaster(r, crs=newproj, res=20000)
# inverse projection, back to the properties of 'r'
inv <- projectRaster(pr2, r)
# to have more control, provide an existing Raster object, here we create one
# using projectExtent (no values are transferred)
pr3 <- projectExtent(r, newproj)
# Adjust the cell size
res(pr3) <- 200000
# now project
pr3 <- projectRaster(r, pr3)
Run the code above in your browser using DataLab