## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>",
                      fig.width = 6, fig.height = 4.5)

## ----setup--------------------------------------------------------------------
library(sptrends)

## -----------------------------------------------------------------------------
r <- read_ordered_stack(example_data("vhp_ndvi"))
r
terra::nlyr(r)
terra::time(r)

## ----fig.width = 10, fig.height = 11, fig.alt = "Mosaic of all annual mean NDVI layers in temporal order"----
ndvi_col <- rev(grDevices::hcl.colors(50, "Greens 3"))
terra::plot(
  r, col = ndvi_col, colNA = "transparent", nc = 6,
  maxnl = terra::nlyr(r)
)

## ----eval = FALSE-------------------------------------------------------------
# terra::animate(
#   r,
#   pause = 0.2,
#   main = as.character(terra::time(r)),
#   col = ndvi_col,
#   colNA = "transparent"
# )

## ----explicit-input, eval = FALSE---------------------------------------------
# # ordered_files is your chronological vector of file paths.
# monthly <- read_ordered_stack(
#   files = ordered_files, cycle_type = "monthly",
#   start = as.Date("2001-08-01"), report = FALSE
# )
# seasonal <- compute_anomalies(monthly, cycle_type = "monthly",
#                               start_position = 8)
# result <- workflow_trends(seasonal$anomalies, report = FALSE)

