mergeTime: merge SpatRasters by timelines to create a single timeseries

mergeTimeR Documentation

merge SpatRasters by timelines to create a single timeseries

Description

Combine SpatRasters with partly overlapping time-stamps to create a single time series. If there is no overlap between the SpatRasters there is no point in using this function (use c instead).

Also note that time gaps are not filled. You can use fillTime to do that.

Usage

## S4 method for signature 'SpatRasterDataset'
mergeTime(x, fun=mean, filename="", ...)

Arguments

x

SpatRasterDataset

fun

A function that reduces a vector to a single number, such as mean or min

filename

character. Output filename

...

list with named options for writing files as in writeRaster

Value

SpatRaster

Examples

r <- rast(system.file("ex/logo.tif", package="terra"))   
s1 <- c(r, r)
time(s1) <- as.Date("2001-01-01") + 0:5
s1 <- s1/10
time(s1) <- as.Date("2001-01-07") + 0:5
s2 <- s1*10
time(s2) <- as.Date("2001-01-05") + 0:5
x <- sds(s1, s1, s2)

m <- mergeTime(x, mean)

terra documentation built on Oct. 14, 2024, 5:07 p.m.