if (FALSE) {
dsn <- system.file("extdata", "centralpark.geojson", package = "CDSE")
aoi <- sf::read_sf(dsn, as_tibble = FALSE)
cloudless_images <- SearchCatalog(aoi = aoi, from = "2023-01-01", to = "2023-12-31",
collection = "sentinel-2-l2a", with_geometry = TRUE,
filter = "eo:cloud_cover < 0.8", client = OAuthClient)
script_file <- system.file("scripts", "NDVI_float32.js", package = "CDSE")
days <- rev(cloudless_images$acquisitionDate)
lstRast <- lapply(days, GetImageByTimerange, aoi = aoi, collection = "sentinel-2-l2a",
script = script_file, file = NULL, format = "image/tiff", mosaicking_order = "mostRecent",
resolution = 10, buffer = 0, mask = TRUE, client = OAuthClient,
url = getOption("CDSE.process_url"))
par(mfrow = c(3, 4))
sapply(seq_along(days), FUN = function(i) {
ras <- lstRast[[i]]
day <- days[i]
ras[ras < 0] <- 0
terra::plot(ras, main = paste("Central Park NDVI on", day), range = c(0, 1),
cex.main = 0.7, pax = list(cex.axis = 0.5), plg = list(cex = 0.5),
col = colorRampPalette(c("darkred", "yellow", "darkgreen"))(99))
})
}
Run the code above in your browser using DataLab