Learn R Programming

raster (version 1.9-19)

area: Size of cells

Description

Compute the approximate surface area of cells in an unprojected (longitude/latitude) RasterLayer. It is an approximation because area is computed as the height (latitudial span) of a cell (which is constant among all cells) times the width (longitudinal span) in the (latitudinal) middle of a cell. The width is smaller at the poleward side than at the equator-ward side of a cell. This variation is greatest near the poles and the values are thus not very precise for very high latitudes.

Usage

area(x, ...)

Arguments

x
a Raster* object
...
Additional arguments, see Details

Value

  • a RasterLayer. Cell values represent the size of the cell in km2, or the relative size if weights=TRUE

Details

The following additional arguments can be passed, to replace default values for this function rll{ na.rm=FALSE Logical. If TRUE, cells that are NA in x are ignored weights=FALSE Logical. If TRUE, area of each cells is divided by the total area of all cells that are not NA filename Filename for the output RasterLayer format Character. Output file type. See writeRaster datatype Character. Output data type. See dataType overwrite Logical. If TRUE, "filename" will be overwritten if it exists progress Character. Choose from "text", "window", or "" (the default, no progress bar) } If x is a RasterStack/Brick, a RasterBrick will be returned if na.rm=TRUE. However, if na.rm=FALSE, a RasterLayer is returned, because the values would be the same for all layers.

Examples

Run this code
r <- raster(nrow=18, ncol=36)
a <- area(r)

Run the code above in your browser using DataLab