Skip to content

RS_SetBandNoDataValue

Sets the nodata value of the specified band, packing the value into the band’s native data type. A null raster or band yields a null raster; a null nodata value instead clears the addressed band’s nodata. This is metadata-only: raster cell values are not modified.

Usage

raster RS_SetBandNoDataValue(rast: raster, nodata: float64)
raster RS_SetBandNoDataValue(rast: raster, band: int, nodata: float64)

Arguments

  • rast (raster): Input raster
  • band (int): Band index (1-based).
  • nodata (float64): Nodata value to set, or null to clear the band’s nodata. The raster must be single-band; for a multiband raster, specify the band with the three-argument form below.

Examples

SELECT RS_BandNoDataValue(RS_SetBandNoDataValue(RS_Example(), 1, 0), 1);
┌──────────────────────────────────────────────────────────────────────────────┐
│ rs_bandnodatavalue(rs_setbandnodatavalue(rs_example(),Int64(1),Int64(0)),Int │
│                                    64(1))…                                   │
╞══════════════════════════════════════════════════════════════════════════════╡
│                                                                          0.0 │
└──────────────────────────────────────────────────────────────────────────────┘
SELECT RS_BandNoDataValue(RS_SetBandNoDataValue(RS_Example(), 2, 255), 2);
┌──────────────────────────────────────────────────────────────────────────────┐
│ rs_bandnodatavalue(rs_setbandnodatavalue(rs_example(),Int64(2),Int64(255)),I │
│                                   nt64(2))…                                  │
╞══════════════════════════════════════════════════════════════════════════════╡
│                                                                        255.0 │
└──────────────────────────────────────────────────────────────────────────────┘

A null nodata value clears the band’s existing nodata, so the getter reads back null:

SELECT RS_BandNoDataValue(RS_SetBandNoDataValue(RS_Example(), 1, CAST(NULL AS DOUBLE)), 1);
┌──────────────────────────────────────────────────────────────────────────────┐
│ rs_bandnodatavalue(rs_setbandnodatavalue(rs_example(),Int64(1),NULL),Int64(1 │
│                                      ))…                                     │
╞══════════════════════════════════════════════════════════════════════════════╡
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘