cellSize,GRaster-method | R Documentation |
cellArea()
returns a raster will cell values equal to their area. To get the area of all cells of a raster, see expanse()
.
## S4 method for signature 'GRaster'
cellSize(x, mask = FALSE, lyrs = FALSE, unit = "meters2")
x |
A |
mask |
Logical: If |
lyrs |
Logical:
|
unit |
Character: Units of area. Partial matching is used, and case is ignored. Can be any of:
|
A GRaster
.
terra::cellSize()
, expanse()
, zonalGeog()
, omnibus::convertUnits()
if (grassStarted()) {
# Setup
library(terra)
# Elevation raster
madElev <- fastData("madElev")
# Convert a SpatRaster to a GRaster:
elev <- fast(madElev)
# Cell size, no masking, single layer
cs1 <- cellSize(elev)
plot(cs1)
# Cell size, with masking, single layer
cs2 <- cellSize(elev, mask = TRUE)
plot(cs2)
# Cell size, no masking, multilayer
elev2 <- c(elev, log(elev - 200))
cs3 <- cellSize(elev2)
plot(cs3)
# Cell size, masking by 1st layer, multilayer (ignores subsequent layers)
cs4 <- cellSize(elev2, mask = TRUE)
plot(cs4)
# Cell size, masking by each layer, multilayer
cs5 <- cellSize(elev2, mask = TRUE, lyrs = TRUE)
plot(cs5)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.