R Under development (unstable) (2024-07-13 r86895 ucrt) -- "Unsuffered Consequences" 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)) > tif = system.file("tif/L7_ETMs.tif", package = "stars") > x = read_stars(tif) > (xx = x[,c(1:347,349),c(1:350,352),]) # rectilinear: one-but-last row & col missing 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.9915 86 255 dimension(s): from to refsys point x 1 348 SIRGAS 2000 / UTM zone 25S FALSE y 1 351 SIRGAS 2000 / UTM zone 25S FALSE band 1 6 NA NA values x/y x [288790.5,288819),...,[298708.5,298737) [x] y [9120747,9120718),...,[9110743,9110715) [y] band NULL > image(xx) # chooses useRaster itself > # see also tidy.R for a ggplot example, leaving out the row. > > m = matrix(1:16, 4, 4) > x = 1:4 > y = 2:5 > (st = st_as_stars(list(m = m), dimensions = st_dimensions(x = x, y = y))) stars object with 2 dimensions and 1 attribute attribute(s): Min. 1st Qu. Median Mean 3rd Qu. Max. m 1 4.75 8.5 8.5 12.25 16 dimension(s): from to offset delta point x/y x 1 4 1 1 FALSE [x] y 1 4 2 1 FALSE [y] > st = st_set_dimensions(st, 1, values = c(1,2,3,4,6)) > st = st_set_dimensions(st, 2, values = c(2,3,4,5,8)) > try(st_set_dimensions(st, 2, values = c(2,3,4,5,8,20))) # one too many Error in st_set_dimensions(st, 2, values = c(2, 3, 4, 5, 8, 20)) : length of values ( 6 ) does not match length of dimension 2 ( 4 ) > > # $<-.stars: > st$foo = st$m * 2 > st stars object with 2 dimensions and 2 attributes attribute(s): Min. 1st Qu. Median Mean 3rd Qu. Max. m 1 4.75 8.5 8.5 12.25 16 foo 2 9.50 17.0 17.0 24.50 32 dimension(s): from to point values x/y x 1 4 FALSE [1,2),...,[4,6) [x] y 1 4 FALSE [2,3),...,[5,8) [y] > > # st_as_sf: > > if (utils::packageVersion("sf") > "0.7.2") { + plot(st_as_sf(st, as_points = FALSE), axes = TRUE) + } > > image(st, text_values = TRUE, axes = TRUE) > > proc.time() user system elapsed 1.12 0.18 1.29