# `gdal raster fill-nodata`

Added in version 3.11.

Fill nodata raster regions by interpolation from edges

## Synopsis

    Usage: gdal raster fill-nodata [OPTIONS] <INPUT> <OUTPUT>

    Fill nodata raster regions by interpolation from edges.

    Positional arguments:
      -i, --input <INPUT>                                  Input raster dataset [required]
      -o, --output <OUTPUT>                                Output raster dataset (created by algorithm) [required]

    Common Options:
      -h, --help                                           Display help message and exit
      --json-usage                                         Display usage as JSON document and exit
      --config <KEY>=<VALUE>                               Configuration option [may be repeated]
      --progress                                           Display progress bar

    Options:
      -f, --of, --format, --output-format <OUTPUT-FORMAT>  Output format
      --co, --creation-option <KEY>=<VALUE>                Creation option [may be repeated]
      --overwrite                                          Whether overwriting existing output is allowed
      -b, --band <BAND>                                    Input band (1-based index) (default: 1)
      -d, --max-distance <MAX_DISTANCE>                    The maximum distance (in pixels) that the algorithm will search out for values to interpolate. (default: 100)
      -s, --smoothing-iterations <SMOOTHING_ITERATIONS>    The number of 3x3 average filter smoothing iterations to run after the interpolation to dampen artifacts. The default is zero smoothing iterations. (default: 0)
      --mask <MASK>                                        Use the first band of the specified file as a validity mask (zero is invalid, non-zero is valid).
      --strategy <STRATEGY>                                By default, pixels are interpolated using an inverse distance weighting (invdist). It is also possible to choose a nearest neighbour (nearest) strategy.. STRATEGY=invdist|nearest (default: invdist)

    Advanced Options:
      --if, --input-format <INPUT-FORMAT>                  Input formats [may be repeated]

## Description

gdal raster fill-nodata fills nodata areas by interpolating from valid pixels around the edges of the area.

The following options are available:

-f, --of, --format, --output-format <OUTPUT-FORMAT>

  Which output raster format to use. Allowed values may be given by `gdal --formats | grep raster | grep + | sort`

--output-layer <OUTPUT-LAYER>

  Output layer name.

--overwrite

  Allow program to overwrite existing target file or dataset. Otherwise, by default, gdal errors out if the target file or dataset already exists.

-b <BAND>

  Select an input <BAND> to be processed. Bands are numbered from 1. Default is the first band of the input dataset.

-max-distance <MAX_DISTANCE>

  Specifies the maximum distance (in pixels) that the algorithm will search out for values to interpolate. Default is 100 pixels.

--smoothing-iterations <SMOOTHING_ITERATIONS>

  Specifies the number of smoothing iterations to apply to the filled raster. This can help to reduce artifacts in the filled areas. Default is 0 iterations.

--strategy <STRATEGY>

  Select the interpolation <STRATEGY> to use. By default, pixels are interpolated using an inverse distance weighting (invdist). It is also possible to choose a nearest neighbour (nearest) strategy.

--mask <MASK>

  Use the first band of the specified file as a validity mask (zero is invalid, non-zero is valid).

## Examples

### Example 1: Fill nodata areas in a raster

The command specifies to use the second band of the input raster, 50 px max distance, 3 smoothing iterations and the nearest strategy for interpolation. The output will be saved in output.tif.

    gdal raster fill-nodata -b 2 --max-distance 50 --smoothing-iterations 3 \
        --strategy nearest --mask mask.tif \
        input.tif output.tif