Examples for 'stars::mdim'


Read or write data using GDAL's multidimensional array API

Aliases: mdim read_mdim write_mdim

Keywords:

### ** Examples

set.seed(135)
m = matrix(runif(10), 2, 5)
names(dim(m)) = c("stations", "time")
times = as.Date("2022-05-01") + 1:5
pts = st_as_sfc(c("POINT(0 1)", "POINT(3 5)"))
s = st_as_stars(list(Precipitation = m)) |>
 st_set_dimensions(1, values = pts) |>
 st_set_dimensions(2, values = times)
nc = tempfile(fileext=".nc")
if (compareVersion(sf_extSoftVersion()["GDAL"], "3.4.0") > -1) {
  write_mdim(s, nc)
  # try ncdump on the generated file
  print(read_mdim(nc))
}
Warning in CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options,
: GDAL Error 6: SetIndexingVariable() not implemented

Warning in CPL_write_mdim(file, driver, dimx, cdl, wkt, xy, root_group_options,
: GDAL Error 6: SetIndexingVariable() not implemented
stars object with 2 dimensions and 1 attribute
attribute(s):
                     Min.   1st Qu.    Median      Mean  3rd Qu.      Max.
Precipitation  0.03524588 0.3224987 0.3772574 0.4289465 0.511113 0.9204841
dimension(s):
         from to     offset  delta refsys point                   values
stations    1  2         NA     NA     NA  TRUE POINT (0 1), POINT (3 5)
time        1  5 2022-05-02 1 days   Date    NA                     NULL

[Package stars version 0.6-7 Index]