GDAL-RASTER-FILL-NODATA(1)

NAME
gdal-raster-fill-nodata - Fill nodata values in a raster dataset

Added in version 3.11.

SYNOPSIS

    Usage: gdal raster fill-nodata [OPTIONS] <INPUT> <OUTPUT>
    Fill nodata raster regions by interpolation from edges.
    Positional arguments:
      -i, --input <INPUT>                                  Input raster datasets [required]
      -o, --output <OUTPUT>                                Output raster dataset [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]
      -q, --quiet                                          Quiet mode (no progress bar)
    Options:
      -f, --of, --format, --output-format <OUTPUT-FORMAT>  Output format ("GDALG" allowed)
      --co, --creation-option <KEY>=<VALUE>                Creation option [may be repeated]
      --overwrite                                          Whether overwriting existing output is allowed
                                                           Mutually exclusive with --append
      --append                                             Append as a subdataset to existing output
                                                           Mutually exclusive with --overwrite
      -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]
      --oo, --open-option <KEY>=<VALUE>                    Open options [may be repeated]

DESCRIPTION

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

This subcommand is also available as a potential step of gdal raster pipeline (since GDAL 3.12)

OPTIONS

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 rw | sort

--co <NAME>=<VALUE>
    Many formats have one or more optional creation options that can be used to control particulars about the file created. For instance, the GeoTIFF driver supports creation options to control compression, and whether the file should be tiled.

    May be repeated.

    The creation options available vary by format driver, and some simple formats have no creation options at all. A list of options supported for a format can be listed with the --formats command line option but the documentation for the format is the definitive source of information on driver creation options. See Raster drivers format specific documentation for legal creation options for each format.

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

--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).

    Added in version 3.12.

GDALG OUTPUT (ON-THE-FLY / STREAMED DATASET)

This program supports serializing the command line as a JSON file using the GDALG output format. The resulting file can then be opened as a raster dataset using the GDALG: GDAL Streamed Algorithm driver, and apply the specified pipeline in a on-the-fly / streamed way.

NOTE: However this algorithm is not natively streaming compatible. Consequently a temporary dataset will be generated, which may cause significant processing time at opening.

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

AUTHOR
Alessandro Pasotti <elpaso@itopen.it>

COPYRIGHT
1998-2025