pixelArea {ecotrends} | R Documentation |
Average pixel area
Description
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.
Usage
pixelArea(
rast,
type = "mean",
unit = "m",
mask = TRUE,
map = TRUE,
verbosity = 2
)
Arguments
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. |
Value
numeric value
Author(s)
A. Marcia Barbosa, wrapping 'terra' functions by Robert H. Hijmans
See Also
terra::cellSize()
, which this function wraps
Examples
r <- terra::rast(system.file("ex/elev.tif", package = "terra"))
pixelArea(r)
pixelArea(r, unit = "km")