slope_rast: calculate slope of rast object

View source: R/slope_rast.R

slope_rastR Documentation

calculate slope of rast object

Description

calculate slope of rast object

Usage

slope_rast(
  r,
  period = c(2001, 2020),
  outfile = NULL,
  fun = rtrend::slope_mk,
  ...,
  overwrite = FALSE,
  .progress = "text"
)

rast_filter_time(r, period = c(2001, 2020))

Arguments

r

A yearly rast object, which should have time attribute

period

c(year_begin, year_end)

outfile

The path of outputed tiff file. If specified, slope and pvalue will be written into outfile.

fun

the function used to calculate slope, see slope() for details.

...

other parameters ignored

overwrite

logical. If TRUE, outfile is overwritten.

.progress

name of the progress bar to use, see create_progress_bar

Value

A terra rast object, with bands of slope and pvalue.

See Also

terra::rast()

Examples

library(rtrend)
library(terra)

f <- system.file("rast/MOD15A2_LAI_China_G050_2001-2020.tif", package = "rtrend")
r <- rast(f)
r
time(r)

slp <- slope_rast(r,
  period = c(2001, 2020), 
  outfile = "LAI_trend.tif", overwrite = TRUE,
  fun = rtrend::slope_mk, .progress = "none"
)
# if you want to show progress, set `.progress = "text"`
slp
plot(slp)

file.remove("LAI_trend.tif")

rtrend documentation built on June 22, 2024, 11:39 a.m.