> ## 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_SetBandNoDataValue

This sets the no data value for a specified band in the raster. If the band index is not provided, band 1 is assumed by default. Passing a `null` value for `noDataValue` will remove the no data value and that will ensure all pixels are included in functions rather than excluded as no data.

Since `v1.5.1`, this function supports the ability to replace the current no-data value with the new `noDataValue`.

<Note>
  When `replace` is true, any pixels matching the provided `noDataValue` will be considered as no-data in the output raster.

  An `IllegalArgumentException` will be thrown if the input raster does not already have a no-data value defined. Replacing existing values with `noDataValue` requires a defined no-data baseline to evaluate against.

  To use this for no-data replacement, the input raster must first set its no-data value, which can then be selectively replaced via this function.
</Note>

## Signatures

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

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

## Parameters

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

<ParamField body="bandIndex" type="Integer" required>
  The band index value.
</ParamField>

<ParamField body="noDataValue" type="Double" required>
  The NoData value to use for pixels outside the raster extent.
</ParamField>

<ParamField body="replace" type="Boolean">
  The replace value.
</ParamField>

## Return type

<ResponseField type="Raster">
  The resulting raster.
</ResponseField>

## Example

```sql theme={"system"}
SELECT RS_BandNoDataValue(
        RS_SetBandNoDataValue(
            RS_MakeEmptyRaster(1, 20, 20, 2, 22, 2, 3, 1, 1, 0),
            -999
            )
        )
```

```
-999
```
