Skip to content

RS_DimToBand

Promotes a within-band dimension into separate bands.

Usage

raster RS_DimToBand(rast: raster, dim_name: utf8)

Arguments

  • rast (raster): Input raster
  • dim_name (utf8): Name of the dimension to promote (e.g., ‘wavelength’, ‘time’).

[!WARNING]

Experimental. This function is experimental; its behavior may change without notice.

Description

Promotes a named non-spatial dimension into separate bands. Each index along the dimension becomes its own band with that dimension removed. This bridges the gap between the dimension model (where all indices live in one band) and the band model (where each index is a separate band accessible by number).

For example, a raster with 1 band of shape [wavelength=200, y=256, x=256] becomes a raster with 200 bands, each of shape [y=256, x=256]. Standard band math functions can then operate on individual wavelength bands by index.

Bands that do not contain the named dimension are passed through unchanged. If no band carries the named dimension, the function errors — that condition usually signals a typo’d dimension name.

The spatial dimensions (x_dim and y_dim) cannot be promoted.

The inverse operation is RS_BandToDim.

Examples

-- Promote a dimension into separate bands. RS_BandToDim first turns
-- RS_Example()'s bands into a 'band' dimension, which RS_DimToBand reverses.
SELECT RS_DimToBand(RS_BandToDim(RS_Example(), 'band'), 'band');
┌─────────────────────────────────────────────────────────────────────────────┐
│      rs_dimtoband(rs_bandtodim(rs_example(),Utf8("band")),Utf8("band"))     │
│                                    raster                                   │
╞═════════════════════════════════════════════════════════════════════════════╡
│ [64x32/3] @ [43.08 79.07 203.07999999999998 207.07] skew=(1, 1) / OGC:CRS84 │
└─────────────────────────────────────────────────────────────────────────────┘