ts_raster: Assemble/interpolate a raster time series

View source: R/ts_raster.R

ts_rasterR Documentation

Assemble/interpolate a raster time series

Description

This function assembles a raster time series by assigning or interpolating input rasters to a target time series.

Usage

ts_raster(
  r_list,
  r_times,
  out_times = NA,
  fade_raster = FALSE,
  ...,
  verbose = TRUE
)

Arguments

r_list

a list of raster objects.

r_times

POSIXct, a vector of times corresponding to the elements of r_list.

out_times

POSIXct, a vector of times for which output rasters will be created.

fade_raster

(Optional) logical. If TRUE performs a linear interpolation to calculate the values for the output raster. Otherwise uses a nearest temporal neighbor approach. Default is FALSE.

...

additional arguments.

verbose

(Optional) logical. If TRUE outputs progress. Default is TRUE.

Value

a list of raster objects.

Author(s)

Jakob Schwalb-Willmann, Johannes Mast

Examples

#Setup

 library(rtsVis)
 # Load example dataset at a greatly increased interval
x_list <- MODIS_SI_ds[seq(1,length(MODIS_SI_ds),30)]
x_dates <- do.call(c, lapply(MODIS_SI_ds,attr,"time") )[seq(1,length(MODIS_SI_ds),30)]

#Fill NAs
x_list_filled <- ts_fill_na(x_list)

#Make a sequence of output dates, double the length of input dates
out_dates <-seq.POSIXt(from = x_dates[1],
                       to = x_dates[length(x_dates)],length.out = length(x_dates)*2 )

#For each output date, interpolate a raster image from the input files
r_list_out <- ts_raster(r_list = x_list_filled,
                        r_times = x_dates,
                        out_times = out_dates,
                        fade_raster = TRUE)

JohMast/rtsVis documentation built on Oct. 24, 2023, 8:31 p.m.