The water package does not estimate surface reflectance for Landsat 8 and 9. Instead, it uses the products that USGS computes for every scene: Collection 2 Level-2 surface reflectance (SR) and surface temperature (ST). With them, METRIC can run without the raw digital numbers (DN). This vignette uses a small crop of a Landsat 8 Collection 2 Level-2 scene (path 232, row 83, 9 February 2016, near Mendoza, Argentina) included in water. Landsat 9 products have the same structure and are handled the same way.
Download the scene from EarthExplorer, dataset “Landsat 8-9 OLI/TIRS C2 L2”. The package repository also has two step-by-step guides to search and download the scenes for an area and a date range, from the USGS M2M API or from Microsoft Planetary Computer. Among other files, the scene folder contains:
*_SR_B2.TIF to *_SR_B7.TIF: surface
reflectance (blue, green, red, NIR, SWIR1 and SWIR2),*_ST_B10.TIF: surface temperature,*_QA_PIXEL.TIF: quality band, with the cloud mask,*_MTL.txt: metadata, with the acquisition date and
time.A full scene is almost 1 GB, so crop an area of interest when loading
it,
e.g. loadImageSR(path = scene_folder, aoi = createAoi(topleft = c(500000, -3644000), bottomright = c(526000, -3660000), EPSG = 32619)).
loadImageSR() reads the SR bands, rescales them to
reflectance (DN * 0.0000275 - 0.2) and names them B, G, R, NIR, SWIR1
and SWIR2. It also adds the surface temperature as the last layer,
Band_10, in Kelvin (DN * 0.00341802 + 149). Pixels where
any band is outside the valid range (reflectance 0 to 1) are masked in
every layer: 109 pixels here, many of them dense crops with slightly
negative blue reflectance.
library(water)
scene_folder <- system.file("extdata", "L8_C2", package = "water")
image.SR <- loadImageSR(path = scene_folder)
plot(image.SR)Clouds and cloud shadows must be masked before running METRIC,
otherwise they can be selected as cold anchor pixels.
cfmask() reads the QA_PIXEL band and masks
fill, dilated cloud, cirrus, cloud and cloud shadow pixels in all
layers, including the surface temperature. By default it also masks a 60
m buffer around clouds and shadows:
The weather station data are in INTA.csv. With the MTL
file, read.WSdata() also interpolates the weather
conditions at the time of the satellite overpass. The overpass time in
the MTL file is UTC and the station clock uses Argentina time, so we set
tz:
csvfile <- system.file("extdata", "INTA.csv", package = "water")
MTLfile <- list.files(scene_folder, pattern = "MTL.txt$", full.names = TRUE)
WeatherStation <- read.WSdata(WSdata = csvfile, datetime.format = "%Y/%m/%d %H:%M",
columns = c("date" = 1, "time" = 1, "radiation" = 5,
"wind" = 6, "RH" = 3, "temp" = 2, "rain" = 4),
lat = -33.00513, long = -68.86469, elev = 927, height = 2,
tz = "America/Argentina/Mendoza", MTL = MTLfile)## Warning: Radiation at the overpass is 587 W/m2, 68% of the clear-sky value (860
## W/m2): clouds near the station, or a faulty or miscalibrated pyranometer. Check
## the sensor, or use overpass.radiation = "clear-sky"
## Weather Station @ lat: -33.01 long: -68.86 elev: 927
## Summary:
## radiation wind RH ea
## Min. : 0.0 Min. :0.0000 Min. :43.00 Min. :1.751
## 1st Qu.: 0.0 1st Qu.:0.0150 1st Qu.:51.50 1st Qu.:1.830
## Median : 43.0 Median :0.2500 Median :65.00 Median :1.864
## Mean :236.0 Mean :0.7792 Mean :68.25 Mean :1.898
## 3rd Qu.:451.8 3rd Qu.:1.6250 3rd Qu.:89.00 3rd Qu.:1.973
## Max. :793.0 Max. :2.5400 Max. :93.00 Max. :2.125
## temp rain
## Min. :16.73 Min. :0
## 1st Qu.:19.17 1st Qu.:0
## Median :24.74 Median :0
## Mean :23.46 Mean :0
## 3rd Qu.:27.23 3rd Qu.:0
## Max. :29.35 Max. :0
##
## Conditions at satellite overpass:
## datetime radiation wind RH ea temp rain date
## 12 2016-02-09 11:27:29 587.26 1.32 58.25 1.88 25.31 0 2016-02-09
read.WSdata() warns that the station radiation at the
overpass (587 W/m2) is 68% of the clear-sky value. The cold anchor
pixels are calibrated with it, so check the pyranometer, or use
overpass.radiation = "clear-sky" if clouds shaded only the
station. Here we keep the measured value.
With surf.temp, METRIC.EB() uses the
Level-2 surface temperature instead of estimating it from the thermal
band (it would also be used by default,
LST.method = "auto", because image.SR has the
layer Band_10). The satellite is detected from the MTL file
(sat = "auto") and the albedo coefficients are chosen for
the satellite (alb.coeff = "auto": those of Olmedo for
Landsat 8 and 9, Tasumi et al. for Landsat 7). The hot and cold anchor
pixels are selected from percentiles of the NDVI, the albedo and the
surface temperature (anchors.method = "percentile"; see
?calcAnchors), and the sensible heat flux iterates over
them with the aerodynamic resistance (?calcH):
Energy.Balance <- METRIC.EB(image.SR = image.SR, surf.temp = image.SR$Band_10,
WeatherStation = WeatherStation, MTL = MTLfile,
Z.om.ws = 0.03)## Calibration: anchors hot 317.4 K, cold 307.9 K (difference 9.5 K); ETrF > 1.1 on 0.7% of the pixels; u200 2.8 m/s; converged. See summary()
summary() shows the calibration (anchor pixels,
temperature difference dT, wind speed used and the share of pixels with
ETrF above 1.1) so that you can judge it. Read it before using the
results, and see ?plotAnchors to draw the anchors on the
map:
## Anchors: 429 hot and 98 cold (from 2143 hot and 486 cold candidates)
## Ts of the anchors: hot 317.37 K, cold 307.89 K, difference 9.48 K
## dT = 0.2779 * Ts_datum + -81.83; u200 2.77 m/s; converged after 12 iterations
## ETrF at the overpass: 5% 0.2 median 0.71 95% 0.99 max 1.26
## Pixels with ETrF > 1.1: 0.7% ETrF < 0: 1.7% H > Rn - G: 1.7%
Without image.DN, METRIC.EB() computes the
leaf area index and selects the anchor pixels from the surface
reflectance. The LAI equations of METRIC were described for
top-of-atmosphere reflectance, so the results can differ from a run that
also uses the Level-1 data (see the last section).
Finally, ET24h() takes the energy balance and returns
the instantaneous ET (ETinst, mm/h), the reference ET
fraction (ETrF, the crop coefficient with respect to
alfalfa), the daily ET (ET24, mm/day) and the pixels where
H is larger than Rn - G (HgtRnG). The daily reference ET
(ETr, ASCE-EWRI 2005) of the day of the image comes from the weather
station:
## The record of 24:00 on 2016-02-09 (00:00 of the next day) is missing: the last hour (at night) is not included
The message about the record of 24:00 is not an error: the weather
station file ends at 23:00 of the day, so the last hour of the day (at
night) is left out of the daily ETr, which follows the ASCE-EWRI (2005)
day of hourly periods ending at 01:00 to 24:00. A day with more missing
hours gives NA, and then you must provide the daily ETr
(ETr.daily) from another source.
For a season, the ETrF of several images can be interpolated and
added up with ETperiod(), using the daily reference ET of
every day from dailyETseries().
If the Level-1 product of the same scene is also available (dataset
“Landsat 8-9 OLI/TIRS C2 L1” in EarthExplorer), it can be loaded with
loadImage() and passed as image.DN.
METRIC.EB() then uses the top-of-atmosphere reflectance for
the leaf area index and the anchor pixels and, with
LST.method = "METRIC", estimates the surface temperature
from the thermal band with the equations of METRIC (Eqs. 20-21) instead
of using the Level-2 product. The Level-1 example files included in
water are from the same scene, with the older
(pre-Collection) file names:
image.DN <- loadImage(path = system.file("extdata", package = "water"), sat = "L8")
MTL.L1 <- system.file("extdata", "LC82320832016040LGN00_MTL.txt", package = "water")
Energy.Balance.DN <- METRIC.EB(image.DN = image.DN, image.SR = image.SR,
WeatherStation = WeatherStation, MTL = MTL.L1,
sat = "L8", LST.method = "METRIC",
Z.om.ws = 0.03)## Warning: With the general atmospheric values of Allen et al. (2007), the
## Landsat 8/9 surface temperature can be biased by several K: use the Level-2
## surface temperature (image.SR$Band_10), or the atmosphere argument
## Calibration: anchors hot 309.4 K, cold 303.1 K (difference 6.3 K); ETrF > 1.1 on 4.3% of the pixels; u200 2.8 m/s; converged. See summary()
The warning about the atmosphere above is expected here: without the Level-2 product, the surface temperature from the thermal band uses general atmospheric values and can be biased by several K for Landsat 8 and 9. Prefer the Level-2 surface temperature, as in the first run.