calc_cellarea: Calculate the cell area of LPJmL cells

View source: R/calc_cellarea.R

calc_cellareaR Documentation

Calculate the cell area of LPJmL cells

Description

Calculate the cell area of LPJmL cells based on an LPJmLData object or latitude coordinates and grid resolution. Uses a spherical representation of the Earth.

Usage

calc_cellarea(
  x,
  cellsize_lon = 0.5,
  cellsize_lat = cellsize_lon,
  earth_radius = 6371000.785,
  return_unit = "m2"
)

Arguments

x

LPJmLData object with ⁠$grid⁠ attribute, an LPJmLData object of variable "grid" ("LPJGRID") or a vector of cell-center latitude coordinates in degrees.

cellsize_lon

Grid resolution in longitude direction in degrees (default: 0.5). If x is an LPJmLData object the resolution will be taken from the meta data included in x if available.

cellsize_lat

Grid resolution in latitude direction in degrees (default: same as cellsize_lon). If x is an LPJmLData object the resolution will be taken from the meta data included in x if available.

earth_radius

Radius of the sphere (in m) used to calculate the cell areas.

return_unit

Character string describing the area unit of the returned cell areas. Defaults to "m2", further options: "ha" or "km2".

Value

A vector or array matching the space dimension(s) of x if x is an LPJmLData object. A vector of the same length as x if x is a vector of latitude coordinates. Cell areas are returned in the unit return_unit.

Examples

grid <- matrix(
  data = c(-179.75, 89.75, -0.25, 0.25, 0.25, -0.25, 179.75, -89.75),
  ncol = 2,
  byrow = TRUE,
  dimnames = list(NULL, c("lon", "lat"))
)
gridarea <- calc_cellarea(grid[,"lat"])


lpjmlkit documentation built on March 31, 2023, 9:35 p.m.