only for yearly rast
library(rtrend)
library(terra)
#> terra 1.7.83
f = system.file("rast/MOD15A2_LAI_China_G050_2001-2020.tif", package = "rtrend")
r = rast(f)
r
#> class : SpatRaster
#> dimensions : 80, 140, 20 (nrow, ncol, nlyr)
#> resolution : 0.5, 0.5 (x, y)
#> extent : 70, 140, 15, 55 (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326)
#> source : MOD15A2_LAI_China_G050_2001-2020.tif
#> names : LAI, LAI, LAI, LAI, LAI, LAI, ...
#> min values : 0.000000, 0.000000, 0.000000, 0.00000, 0.000000, 0.000000, ...
#> max values : 5.692542, 5.479348, 5.585326, 5.33587, 5.822826, 5.533152, ...
#> time : 978307200 to 1577836800
time(r)
#> [1] 978307200 1009843200 1041379200 1072915200 1104537600 1136073600
#> [7] 1167609600 1199145600 1230768000 1262304000 1293840000 1325376000
#> [13] 1356998400 1388534400 1420070400 1451606400 1483228800 1514764800
#> [19] 1546300800 1577836800
slp <- slope_rast(r, period = c(2001, 2020),
outfile = "LAI_trend.tif", overwrite = TRUE,
fun = rtrend::slope_mk, .progress = "none"
)
#> Warning: tz(): Don't know how to compute timezone for object of class numeric;
#> returning "UTC".
slp
#> class : SpatRaster
#> dimensions : 80, 140, 2 (nrow, ncol, nlyr)
#> resolution : 0.5, 0.5 (x, y)
#> extent : 70, 140, 15, 55 (xmin, xmax, ymin, ymax)
#> coord. ref. : lon/lat WGS 84 (EPSG:4326)
#> source(s) : memory
#> names : slope, pvalue
#> min values : -0.01830315, 0
#> max values : 0.04475858, 1
#> [1] TRUE