Skip to content

Commit

Permalink
Merge pull request #553 from weecology/ndvi-terra
Browse files Browse the repository at this point in the history
Update landsat api date format [minor]
  • Loading branch information
gmyenni authored Nov 4, 2024
2 parents 06d4025 + 03fbfb3 commit 00a07c5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions DataCleaningScripts/update_ndvi.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
#'
Expand Down Expand Up @@ -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)

Expand All @@ -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,
Expand Down

0 comments on commit 00a07c5

Please sign in to comment.