# Define raster resolution in UTM or Lambert Azimuth Equal Area projection

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)
``````
• I'm really having a hard time trying to figure out what you're doing. Can you provide more details? Jul 23, 2022 at 22:55
• I am doing a kernel density analysis of seabird tracking data using adehabitatHR package. This analysis should be done in LAEA projection. The inputs for the model is (a) the seabird tracks (b) a smoother, and (c) a grid across which the utilisation distribution is modelled. I want the grid to be at a resolution of 10 km. Jul 24, 2022 at 10:07

If you define the CRS while creating the raster, this issue will be solved.

Try the following code

``````library(raster)
## create a raster in LAEA
r_ext = extent(c(-665870.2, 452829.8, -643224., 357575.7))
r_res = 10
r_crs = "+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 = raster(ext=r_ext, res=c(r_res, r_res),
crs = r_crs)
print(ras)
``````
• Oh wow! That certainly seems to do the trick - thank you so much! So just to clarify - a resolution of 10 is 10 m, correct? I found this last night, where I realised that the raster has to be built differently in UTM/LAEA projection. neonscience.org/resources/learning-hub/tutorials/… You have just confirmed this and provided a much more simple answer Jul 24, 2022 at 10:13
• Yes unit of the resolution is same as the unit of projection/CRS being used. Jul 24, 2022 at 12:30