calcTOAr: Calculates top-of-atmosphere reflectance

View source: R/water_RSfunctions.R

calcTOArR Documentation

Calculates top-of-atmosphere reflectance

Description

Calculates the TOA (top-of-atmosphere) reflectance, divided by the cosine of the solar incidence angle of each pixel. For Landsat 8 and 9 the reflectance rescaling coefficients of the Level-1 products (2e-05 and -0.1) are used; for Landsat 7, the gains, biases and ESUN values of the Landsat 7 handbook and the acquisition date in the MTL file.

Usage

calcTOAr(image.DN, sat = "auto", incidence.rel, MTL, aoi)

Arguments

image.DN

raw image in digital numbers, e.g. from loadImage(). Bands B, G, R, NIR, SWIR1 and SWIR2 are used. Layers are selected by name; a stack without the standard names is used by position, with a warning, and a stack with these names that lacks a needed layer is an error.

sat

"L7", "L8", "L9" or "auto" to detect it from the MTL file (MTL is then required)

incidence.rel

solar incidence angle (radians) considering the relief, from solarAngles()

MTL

path to the Landsat metadata (*_MTL.txt) file. Needed for Landsat 7 and for sat = "auto"

aoi

Not used (a warning is given when it is passed). Crop the inputs beforehand (e.g. loadImage(..., aoi = aoi))

Value

SpatRaster with top-of-atmosphere reflectance (unitless) in layers B, G, R, NIR, SWIR1 and SWIR2.

Author(s)

Guillermo Federico Olmedo

David Fonseca-Luengo

References

R. G. Allen, M. Tasumi, and R. Trezza, "Satellite-based energy balance for mapping evapotranspiration with internalized calibration (METRIC) - Model" Journal of Irrigation and Drainage Engineering, vol. 133, p. 380, 2007

LPSO. (2004). Landsat 7 science data users handbook, Landsat Project Science Office, NASA Goddard Space Flight Center, Greenbelt, Md., (http://landsathandbook.gsfc.nasa.gov/) (Feb. 5, 2007)

U.S. Geological Survey (2019). Landsat 8 (L8) Data Users Handbook, LSDS-1574. EROS, Sioux Falls, South Dakota. https://www.usgs.gov/landsat-missions/landsat-8-data-users-handbook

See Also

Other remote sensing support functions: calcRadiance(), calcSR(), cfmask(), loadImage(), loadImageSR()

Examples

# a small window of the Landsat 7 example scene, to run quickly
MTL <- system.file("extdata", "L7.MTL.txt", package = "water")
WeatherStation <- read.WSdata(WSdata = system.file("extdata", "apples.csv", package = "water"),
  date.format = "%d/%m/%Y", lat = -35.42222, long = -71.38639, elev = 201, height = 2.2,
  cf = c(1, 0.2777778, 1), tz = "America/Santiago", MTL = MTL)
image.DN <- terra::rast(L7_Talca)[1:60, 1:80, drop = FALSE]
DEM <- terra::rast(DEM_Talca)[1:60, 1:80, drop = FALSE]
surface.model <- METRICtopo(DEM)
solar.angles <- solarAngles(surface.model = surface.model,
                            WeatherStation = WeatherStation, MTL = MTL)
image.TOAr <- calcTOAr(image.DN, sat = "L7", MTL = MTL,
                       incidence.rel = solar.angles$incidence.rel)
plot(image.TOAr)

water documentation built on Nov. 25, 2026, 5:08 p.m.