From 03fbfb30c6d188a514fd55d3e970bce8687a95a2 Mon Sep 17 00:00:00 2001 From: Glenda Yenni Date: Mon, 4 Nov 2024 12:59:00 -0700 Subject: [PATCH] Update landsat api date format [minor] --- DataCleaningScripts/update_ndvi.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DataCleaningScripts/update_ndvi.R b/DataCleaningScripts/update_ndvi.R index 14d2b275..9c5b95b1 100644 --- a/DataCleaningScripts/update_ndvi.R +++ b/DataCleaningScripts/update_ndvi.R @@ -3,7 +3,7 @@ # https://www.usgs.gov/landsat-missions/landsat-collection-2-level-2-science-products `%>%` <- magrittr::`%>%` -library(terra) +library(terra, warn.conflicts=FALSE, quietly = TRUE) #' @title create_portal_area #' @@ -84,7 +84,7 @@ summarize_ndvi_snapshot <- function(records, targetpath = tempdir()) { print(records["display_id"]) source <- "USGS" sensor <- paste0("Landsat", records["satellite"]) - date <- as.Date(records["acquisition_date"]) + date <- lubridate::ymd_hms(format(records["acquisition_date"], format = "%Y-%m-%d %T %Z")) r <- extract_and_mask_raster(records, targetpath) @@ -96,7 +96,7 @@ summarize_ndvi_snapshot <- function(records, targetpath = tempdir()) { md <- median(values(r),na.rm=T) mi <- min(values(r),na.rm=T) ma <- max(values(r),na.rm=T) - va <- var(values(r),na.rm=T) + va <- var(values(r),na.rm=T)[1,1] pix <- length(values(r)) d <- data.frame(date = as.Date(date), sensor = sensor, source = source,