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. > Sys.setenv(TZ="") > suppressPackageStartupMessages(library(stars)) > matrix(1:4,2) [,1] [,2] [1,] 1 3 [2,] 2 4 > m = matrix(1:4,2) > s = st_as_stars(m) > > s = st_set_dimensions(s, st_dimensions(s), xy = NULL) > sfc = st_sfc(st_point(0:1), st_point(3:2)) > s = st_set_dimensions(s, 1, sfc) |> st_set_crs(4326) > tm = as.POSIXct("2023-03-04 12:35") + c(0, 3600) > s = st_set_dimensions(s, 2, tm) > f = tempfile(fileext = ".nc") > write_mdim(s, f, as_float = FALSE) Warning messages: 1: In CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options, : GDAL Error 6: SetIndexingVariable() not implemented 2: In CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options, : GDAL Error 6: SetIndexingVariable() not implemented > s2 = read_mdim(f) > #print(s2) > print(all.equal(s, s2, check.attributes = FALSE)) [1] TRUE > print(all.equal(s, s2)) [1] "Attributes: < Component \"dimensions\": Component \"X1\": Component \"refsys\": Component \"input\": 1 string mismatch >" [2] "Attributes: < Component \"dimensions\": Component \"X1\": Component \"refsys\": Component \"wkt\": 1 string mismatch >" [3] "Attributes: < Component \"dimensions\": Component \"X1\": Component \"values\": Attributes: < Component \"crs\": Component \"input\": 1 string mismatch > >" [4] "Attributes: < Component \"dimensions\": Component \"X1\": Component \"values\": Attributes: < Component \"crs\": Component \"wkt\": 1 string mismatch > >" [5] "Attributes: < Component \"dimensions\": Component \"X2\": Component \"offset\": 'tzone' attributes are inconsistent ('' and 'UTC') >" [6] "Attributes: < Component \"dimensions\": Component \"X2\": Component \"point\": 'is.NA' value mismatch: 1 in current 0 in target >" > > st_crs(sfc) = st_crs(s2) > st_crs(s) = st_crs(s2) > tm = as.Date("2023-02-25") + 0:1 > sd = st_set_dimensions(s, 2, tm) > print(sd) stars object with 2 dimensions and 1 attribute attribute(s): Min. 1st Qu. Median Mean 3rd Qu. Max. A1 1 1.75 2.5 2.5 3.25 4 dimension(s): from to offset delta refsys point values X1 1 2 NA NA WGS 84 TRUE POINT (0 1), POINT (3 2) X2 1 2 2023-02-25 1 days Date FALSE NULL > sd = st_set_dimensions(sd, 1, sfc) > print(sd) stars object with 2 dimensions and 1 attribute attribute(s): Min. 1st Qu. Median Mean 3rd Qu. Max. A1 1 1.75 2.5 2.5 3.25 4 dimension(s): from to offset delta refsys point values X1 1 2 NA NA WGS 84 TRUE POINT (0 1), POINT (3 2) X2 1 2 2023-02-25 1 days Date FALSE NULL > f = tempfile(fileext = ".nc") > write_mdim(sd, f) Warning messages: 1: In CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options, : GDAL Error 6: SetIndexingVariable() not implemented 2: In CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options, : GDAL Error 6: SetIndexingVariable() not implemented > sd2 = read_mdim(f) > print(sd2) stars object with 2 dimensions and 1 attribute attribute(s): Min. 1st Qu. Median Mean 3rd Qu. Max. A1 1 1.75 2.5 2.5 3.25 4 dimension(s): from to offset delta refsys point values X1 1 2 NA NA WGS 84 TRUE POINT (0 1), POINT (3 2) X2 1 2 2023-02-25 1 days Date NA NULL > print(all.equal(sd, sd2, check.attributes = FALSE)) [1] TRUE > print(all.equal(sd, sd2)) [1] "Attributes: < Component \"dimensions\": Component \"X2\": Component \"point\": 'is.NA' value mismatch: 1 in current 0 in target >" > # if (.Platform$OS.type == "unix") { > # print(read_mdim(paste0("/vsizip/", (system.file("zarr/sic_daily_sample.zarr.zip", package = "stars")))) > # } > > proc.time() user system elapsed 0.64 0.12 0.75