I want to create a raster grid in Lambert Azimuth Equal Area projection. I need to work within the raster and sp packages, and I need to work in LAEA projection. However, when creating my raster, my raster cell sizes appear to be the same regardless of what resolution I define. This is not the case if I work in WGS, but it is the case if I work in UTM
library(raster)
## create a raster in LAEA
ras = raster(ext=extent(c(-665870.2, 452829.8, -643224., 357575.7), res=c(10000000, 10000000)))
#Warning message: In extent(c(-665870.2, 452829.8, -643224, 357575.7), res = c(1e+07, : more elements than expected (should be 4)
ras[] <- 1
projection(ras) <- "+proj=aeqd +lat_0=-51.71475 +lon_0=-61.313002 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
ras
#class : RasterLayer
#dimensions : 180, 360, 64800 (nrow, ncol, ncell)
#resolution : 3107.5, 5559.998 (x, y)
#extent : -665870.2, 452829.8, -643224, 357575.7 (xmin, xmax, ymin, ymax)
#crs : +proj=aeqd +lat_0=-51.71475 +lon_0=-61.313002 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs
#source : memory
#names : layer
#values : 1, 1 (min, max)
## Now choose a different resolution
ras = raster(ext=extent(c(-665870.2, 452829.8, -643224., 357575.7 ), res=c(10,10)))
#Warning message:In extent(c(-665870.2, 452829.8, -643224, 357575.7), res = c(10, : more elements than expected (should be 4)
ras[] <- 1
projection(ras) <- "+proj=aeqd +lat_0=-51.71475 +lon_0=-61.313002 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs"
ras
## It's the same!!!
#class : RasterLayer
#dimensions : 180, 360, 64800 (nrow, ncol, ncell)
#resolution : 3107.5, 5559.998 (x, y)
#extent : -665870.2, 452829.8, -643224, 357575.7 (xmin, xmax, ymin, ymax)
#crs : +proj=aeqd +lat_0=-51.71475 +lon_0=-61.313002 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs
#source : memory
#names : layer
#values : 1, 1 (min, max)
Perhaps this is to do with the warning message? The same message appears if I build a raster in UTM. I haven't been able to find out why this warning message shows up; it doesn't appear if I work in WGS, and the rasters are different with different specified resolutions, as you would expect:
library(raster)
## create a raster in WGS
ras = raster(ext=extent(c(-69.5, -56, -56, -49)), res=c(1,1))
ras[] <- 1
projection(ras) <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
ras
#class : RasterLayer
#dimensions : 7, 14, 98 (nrow, ncol, ncell)
#resolution : 1, 1 (x, y)
#extent : -69.5, -55.5, -56, -49 (xmin, xmax, ymin, ymax)
#crs : +proj=longlat +datum=WGS84 +no_defs
#source : memory
#names : layer
#values : 1, 1 (min, max)
## Now choose a different resolution
ras = raster(ext=extent(c(-69.5, -56, -56, -49)), res=c(0.1,0.1))
ras[] <- 1
projection(ras) <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
ras
#class : RasterLayer
#dimensions : 70, 135, 9450 (nrow, ncol, ncell)
#resolution : 0.1, 0.1 (x, y)
#extent : -69.5, -56, -56, -49 (xmin, xmax, ymin, ymax)
#crs : +proj=longlat +datum=WGS84 +no_defs
#source : memory
#names : layer
#values : 1, 1 (min, max)