Reputation: 81
Is there a good method for determining the size of individual grid cells in a RasterLayer
? I can access the resolution but I need the actual size in km^2. I've tried using the area()
with my raster but it's not finding the window. I've also tried creating a SpatialGridDataFrame
from my raster but have had no luck computing the area of each individual grid cell. Any help would be appreciated.
Upvotes: 5
Views: 4360
Reputation: 47061
The cells size is the product of the x and y resolution prod(res(x))
if you have a planar coordinate reference system. Otherwise, if your crs is longitude/latitude, cell size will change with latitude, and you can indeed use the area
function to get the size of each cell.
I take it that "it's not finding the window." refers to this error message Error in as.owin.default(w) : Can't interpret W as a window
.
This is a name conflict with spatstat
. So either do not load spatstat
or call the raster function explicitly raster::area(x)
.
Upvotes: 6