[R-sig-Geo] Determining the area of grid cells from a raster in R

Alex Fitz afitz at email.wm.edu
Wed Jun 8 21:49:24 CEST 2016


Hi,

I have a raster and I am trying to get the area of each grid cell.  The raster object is a country and I am trying to get the area of my grid cells so I can calculate density.

When I type in the name of my raster this is the output I get:

class       : RasterLayer 
dimensions  : 1155, 1441, 1664355  (nrow, ncol, ncell)
resolution  : 0.008333333, 0.008333333  (x, y)
extent      : 2.666667, 14.675, 4.266667, 13.89167  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
data source : /private/var/folders/jw/ynhy9rqn0b3bhrsdfs3qt_bw0000gn/T/RtmpJd12I7/raster/r_tmp_2016-06-08_142202_13015_34709.grd 
names       : gpw.v4.population.count.adjusted.to.2015.unwpp.country.totals_2015 
values      : 0, 65434.81  (min, max)


I have tried using the area() function but get the following Error message:
Error in as.owin.default(w) : Can't interpret W as a window


Any help would be greatly appreciated.

Best,
Alex Fitz



More information about the R-sig-Geo mailing list