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.
Raster Resolution or "Cell Size"Cell size = Spatial Resolution: the dimension of the area covered on the ground and represented by a single pixel (e.g., 10m). A LandSat image has a resolution of 30 meters which means each pixel is about 90 feet by 90 feet square.
In order to get the cell size in meter, you need to change the projection of your raster from WGS84 to meter projection such as UTM or any other projections that is meter unit depending of the size of the study area.
Smaller cell sizes result in larger raster datasets to represent an entire surface; therefore, there is a need for greater storage space, which often results in longer processing time.
Right-click the layer in the table of contents and click Properties. Click the Display tab. Check Display raster resolution in the table of contents. Click OK.
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)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With