pixelArea | R Documentation |
This function uses the terra::cellSize()
function to compute (and optionally map) the area covered by each (optionally non-NA) pixel in a raster map; and then it computes either the mean or the centroid pixel area in that map, for an idea of pixel size in that region. Pixel size can vary widely across latitudes, especially in unprojected longitude-latitude rasters, but also in rasters projected to other non-equal-area coordinate reference systems.
pixelArea(
rast,
type = "mean",
unit = "m",
mask = TRUE,
map = TRUE,
verbosity = 2
)
rast |
SpatRaster for which to compute the pixel area |
type |
character value indicating whether the output value should be the "mean" (default) or "centroid" pixel area |
unit |
numeric value indicating the units for the output value: either "m" (default) or "km" squared. |
mask |
logical value (default TRUE) indicating whether to consider only the areas of non-NA pixels |
map |
logical value (default TRUE) indicating whether to also plot a map |
verbosity |
integer value indicating the amount of messages to display. The default is 2, for the maximum number of messages available. |
numeric value
A. Marcia Barbosa, wrapping 'terra' functions by Robert H. Hijmans
terra::cellSize()
, which this function wraps
r <- terra::rast(system.file("ex/elev.tif", package = "terra"))
pixelArea(r)
pixelArea(r, unit = "km")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.