Computes NDVI from Copernicus Sentinel-2 MSI Level-2A harmonised surface reflectance (COPERNICUS/S2_SR_HARMONIZED) on Google Earth Engine. Cloud and shadow pixels are masked using the Scene Classification Layer (SCL).
Usage
read_sentinel2(
date,
region,
backend = c("rest", "rgee"),
cache = TRUE,
max_tries = 3L,
initial_delay = 1
)Arguments
- date
Character or Date. Acquisition date in
"YYYY-MM-DD"format.- region
An sf::sf,
sf::st_sfc(), orterra::ext()object defining the spatial extent. Required.- backend
Character.
"rest"(default) or"rgee".- cache
Logical. Use disk cache? Default
TRUE.- max_tries
Integer. Retry attempts. Default
3L.- initial_delay
Numeric. Initial retry delay in seconds. Default
1.
Value
A terra::rast() SpatRaster. CRS: EPSG:4326. Values: NDVI
(-1 to 1). NA where SCL indicates cloud, shadow, or snow.
Examples
if (FALSE) { # interactive()
ndvi <- read_sentinel2(date = "2024-06-15",
region = terra::ext(138, 139, -35, -34))
}