calc_rn {evapoRe} | R Documentation |
Calculate Net Radiation (Rn)
Description
Computes net radiation (Rn) based on solar radiation, temperature, and elevation.
Usage
calc_rn(tmax, tmin, rs, elevation, albedo = 0.23, x = NULL)
## S4 method for signature 'missing,missing,missing,missing,missing'
calc_rn(x)
## S4 method for signature 'Raster,Raster,Raster,Raster,ANY'
calc_rn(tmax, tmin, rs, elevation, albedo = 0.23, x = NULL)
## S4 method for signature 'character,character,character,character,ANY'
calc_rn(tmax, tmin, rs, elevation, albedo = 0.23, x = NULL)
Arguments
tmax |
Raster* object or file path for maximum temperature (°C) |
tmin |
Raster* object or file path for minimum temperature (°C) |
rs |
Raster* object or file path for solar radiation (MJ m-2 day-1) |
elevation |
Raster* object or file path for elevation (m) |
albedo |
Numeric, Raster*, or file path for albedo (optional, default = 0.23) |
x |
A 'data.table' with columns: "lon", "lat", "date", "rs", "tmax", "tmin", "elevation", and optionally "albedo" |
Details
For raster inputs, provide individual raster objects or file paths for 'tmax', 'tmin', 'rs', 'elevation', and optionally 'albedo'. For 'data.table' input, provide a single 'data.table' with columns: "lon", "lat", "date", "rs", "tmax", "tmin", "elevation", and optionally "albedo".
Value
RasterBrick or data.table of net radiation values (MJ m-2 day-1)
Examples
# Example using Raster* input
if (requireNamespace("raster", quietly = TRUE)) {
tmax_path <- file.path(tempdir(), "tmax.nc")
tmin_path <- file.path(tempdir(), "tmin.nc")
rs_path <- file.path(tempdir(), "rs.nc")
elev_path <- file.path(tempdir(), "elevation.nc")
if (file.exists(tmax_path) && file.exists(tmin_path) &&
file.exists(rs_path) && file.exists(elev_path)) {
tmax <- raster::brick(tmax_path)
tmin <- raster::brick(tmin_path)
rs <- raster::brick(rs_path)
elev <- raster::brick(elev_path)
rn <- calc_rn(tmax = tmax, tmin = tmin, rs = rs, elevation = elev)
}
}
# Example using data.table input
if (requireNamespace("data.table", quietly = TRUE)) {
dt <- data.table::data.table(
lon = c(10.0, 10.5),
lat = c(45.0, 45.5),
date = as.Date(c("2001-06-01", "2001-06-01")),
tmax = c(28.3, 27.6),
tmin = c(14.1, 13.5),
rs = c(22.5, 21.9),
elevation = c(400, 420)
)
rn_dt <- calc_rn(x = dt)
}