7.9 Redimensioning

  • aperm: transposes an array by permuting the order of dimensions
  • Attributes and dimensions can be swapped, using split and merge
(rs <- split(r))
## stars object with 2 dimensions and 6 attributes
## attribute(s):
##     Min. 1st Qu. Median     Mean 3rd Qu. Max.
## X1    47      67     78 79.14772      89  255
## X2    32      55     66 67.57465      79  255
## X3    21      49     63 64.35886      77  255
## X4     9      52     63 59.23541      75  255
## X5     1      63     89 83.18266     112  255
## X6     1      32     60 59.97521      88  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]
merge(rs, name = "band") |> setNames("L7_ETMs")
## stars object with 3 dimensions and 1 attribute
## attribute(s):
##          Min. 1st Qu. Median     Mean 3rd Qu. Max.
## L7_ETMs     1      54     69 68.91242      86  255
## dimension(s):
##      from  to  offset delta                     refsys point    values x/y
## x       1 349  288776  28.5 SIRGAS 2000 / UTM zone 25S FALSE      NULL [x]
## y       1 352 9120761 -28.5 SIRGAS 2000 / UTM zone 25S FALSE      NULL [y]
## band    1   6      NA    NA                         NA    NA X1,...,X6
  • Multiple stars object with identical dimensions can be combined using c