[GIS] R calculate raster cell size in map units

rraster

I have a RasterLayer and would like to know the cell size. I haven't find any function in the packages :-S . Does someone have an idea ?

info about the RasterLayer

class       : RasterLayer 
dimensions  : 40, 40, 1600  (nrow, ncol, ncell)
resolution  : 0.0001106628, 0.0001106628  (x, y)
extent      : 3.061558, 3.065984, 42.5269, 42.53132  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0 
data source : in memory
names       : layer 
values      : 0, 33  (min, max)

Best Answer

Use the ?area function.

library(raster)
r <- raster()  ## boilerplate longlat raster
ar <- area(r)  ## applies a correction for latitude, to km2