R version 4.4.0 alpha (2024-04-02 r86304 ucrt) Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > suppressPackageStartupMessages(library(stars)) > # predict: > tif = system.file("tif/L7_ETMs.tif", package = "stars") > (x = read_stars(tif)) stars object with 3 dimensions and 1 attribute attribute(s): Min. 1st Qu. Median Mean 3rd Qu. Max. L7_ETMs.tif 1 54 69 68.91242 86 255 dimension(s): from to offset delta refsys point x/y x 1 349 288776 28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] y 1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] band 1 6 NA NA NA NA > st_crs(x) = st_crs(x) # cleans trailing space > model = lm(x~L7_ETMs.tif, head(as.data.frame(x), 50)) > x = predict(x, model) > > (y = read_stars(tif, proxy = TRUE)) stars_proxy object with 1 attribute in 1 file(s): $L7_ETMs.tif [1] "[...]/L7_ETMs.tif" dimension(s): from to offset delta refsys point x/y x 1 349 288776 28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] y 1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] band 1 6 NA NA NA NA > (yp = predict(y, model)) stars_proxy object with 1 attribute in 1 file(s): $L7_ETMs.tif [1] "[...]/L7_ETMs.tif" dimension(s): from to offset delta refsys point x/y x 1 349 288776 28.5 SIRGAS 2000 / UTM zone 25S FALSE [x] y 1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE [y] band 1 6 NA NA NA NA call_list: [[1]] predict(object = object, model = model) attr(,".Environment") This object has pending lazy operations: dimensions as printed may not reflect this. > all.equal(x, st_as_stars(yp)) [1] TRUE > > yy = st_set_dimensions(y, 3, values = paste0("band", 1:6)) > (y_spl = split(yy, 3)) stars_proxy object with 1 attribute in 1 file(s): $L7_ETMs.tif [1] "[...]/L7_ETMs.tif" dimension(s): from to offset delta refsys point values x 1 349 288776 28.5 SIRGAS 2000 / UTM zone 25S FALSE NULL y 1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE NULL band 1 6 NA NA NA NA band1,...,band6 x/y x [x] y [y] band call_list: [[1]] split(x = x, 3) attr(,".Environment") This object has pending lazy operations: dimensions as printed may not reflect this. > as.data.frame(st_as_stars(split(yy, 3)))[1:3,] x y band1 band2 band3 band4 band5 band6 1 288790.5 9120747 69 56 46 79 86 46 2 288819.0 9120747 69 57 49 75 88 49 3 288847.5 9120747 63 52 45 66 75 41 > > proc.time() user system elapsed 2.04 0.23 2.26