> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wherobots.com/llms.txt
> Use this file to discover all available pages before exploring further.

# RS_ReplaceBandNoDataValue

Rewrites a band's existing no-data pixels to `noDataValue` and sets that value as the band's no-data metadata. [RS\_SetBandNoDataValue](/reference/wherobots-db/raster-data/operators/RS_SetBandNoDataValue) changes only the metadata.

Pixels that already equal the new value also become no-data; choose a value exactly representable in the band's pixel type and absent from valid pixels to preserve the same no-data mask.

A pixel matches the existing no-data value numerically: `-0.0` matches `0.0`, and any `NaN` matches a `NaN` no-data value. Other bands are unchanged.

The band must already have a no-data value; otherwise the function throws an `IllegalArgumentException`. A `NULL` raster, band index, or `noDataValue` returns `NULL`.

## Signatures

```sql theme={"system"}
RS_ReplaceBandNoDataValue(raster: Raster, bandIndex: Integer, noDataValue: Double)
```

## Parameters

<ParamField body="raster" type="Raster" required>
  The input raster.
</ParamField>

<ParamField body="bandIndex" type="Integer" required>
  The 1-based band index.
</ParamField>

<ParamField body="noDataValue" type="Double" required>
  The replacement no-data value.
</ParamField>

## Return type

<ResponseField type="Raster">
  A raster with the selected band's existing no-data pixels rewritten and its no-data metadata updated.
</ResponseField>

## Example

The band's no-data value starts at `0`. Moving it to `-9999` preserves the two valid pixels:

```sql theme={"system"}
SELECT RS_Count(
    RS_ReplaceBandNoDataValue(
        RS_AddBandFromArray(
            RS_MakeEmptyRaster(1, 'd', 2, 2, 0, 2, 1),
            array(0d, 1d, 0d, 2d), 1, 0d),
        1, -9999),
    1, true)
```

```
2
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.