Skip to content

Instantly share code, notes, and snippets.

@khufkens
Created April 13, 2022 17:07
Show Gist options
  • Save khufkens/6f602d655073af808583f517a11f23c7 to your computer and use it in GitHub Desktop.
Save khufkens/6f602d655073af808583f517a11f23c7 to your computer and use it in GitHub Desktop.
Calculate optimal span for MODIS time series
# Interpolation using a loess smoother
# and optimal span determination
library(MODISTools)
library(phenocamr)
library(tidyverse)
VI <- mt_subset(
product = "MOD13Q1",
lon = -72.1755,
lat = 42.5388,
band = c("250m_16_days_EVI"),
start = "2004-01-01",
end = "2008-12-30",
km_lr = 0,
km_ab = 0,
site_name = "test",
internal = TRUE
)
# band multiplier
VI <- VI %>%
mutate(
value = value * as.numeric(scale)
)
# optimal span calculation
# for this step frequency
# 16 day interval
span <- phenocamr::optimal_span(
VI$value,
plot = TRUE
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment