GDAL-RASTER-STACK(1)

NAME
gdal-raster-stack - Combine together input bands into a multi-band output, either virtual (VRT) or materialized

Added in version 3.11.

SYNOPSIS

            Usage: gdal raster stack [OPTIONS] <INPUTS>... <OUTPUT>

            Combine together input bands into a multi-band output, either virtual (VRT) or materialized.

            Positional arguments:
              -i, --input <INPUTS>                                            Input raster datasets (or specify a @<filename> to point to a file containing filenames) [1.. values] [required] [not available in pipelines]
              -o, --output <OUTPUT>                                           Output raster dataset [required] [not available in pipelines]

            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 or warning message) [not available in pipelines]

            Options:
              -f, --of, --format, --output-format <OUTPUT-FORMAT>             Output format ("GDALG" allowed) [not available in pipelines]
              --co, --creation-option <KEY>=<VALUE>                           Creation option [may be repeated] [not available in pipelines]
              --overwrite                                                     Whether overwriting existing output dataset is allowed [not available in pipelines]
                                                                              Mutually exclusive with --append
              --append                                                        Append as a subdataset to existing output [not available in pipelines]
                                                                              Mutually exclusive with --overwrite
              -b, --band <BAND>                                               Input band(s) (1-based index) [may be repeated]
              --absolute-path                                                 Whether the path to the input datasets should be stored as an absolute path
              --resolution <xres>,<yres>|same|average|common|highest|lowest>  Target resolution (in destination CRS units) (default: same)
              --bbox <BBOX>                                                   Target bounding box as xmin,ymin,xmax,ymax (in destination CRS units)
              --target-aligned-pixels                                         Round target extent to target resolution
              --input-nodata <INPUT-NODATA>                                   Set nodata values for input bands. [1.. values]
              --output-nodata <OUTPUT-NODATA>                                 Set nodata values at the destination band level. [1.. values]
              --hide-nodata                                                   Makes the destination band not report the NoData.

            Advanced Options:
              --if, --input-format <INPUT-FORMAT>                             Input formats [may be repeated] [not available in pipelines]
              --oo, --open-option <KEY>=<VALUE>                               Open options [may be repeated] [not available in pipelines]

DESCRIPTION

This program combine together input bands from GDAL datasets into a dataset, that can be either a virtual stack in the VRT (Virtual Dataset) format, or in a more conventional raster format such as GeoTIFF.

All bands of each input file are added as separate output bands, unless -b is specified to select a subset of them.

The list of input GDAL datasets can be specified at the end of the command line or put in a text file (one filename per line) for very long lists. Wildcards '*', '?' or '['] of VSIGlob() can be used, even on files located on network file systems such as /vsis3/, /vsigs/, /vsiaz/, etc.

Stating with GDAL 3.12, this command can also be used as the first step of gdal raster pipeline.

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.

PROGRAM-SPECIFIC OPTIONS

    --absolute-path
        Added in version 3.12.0.

        When writing a VRT file, enables writing the absolute path of the input datasets. By default, input filenames are written in a relative way with respect to the VRT filename (when possible).

    -b, --band <band>
        Select an input <band> to be processed. Bands are numbered from 1. If input bands not set all bands will be added to the output. Multiple -b switches may be used to select a set of input bands.

    --bbox <xmin>,<ymin>,<xmax>,<ymax>
        Set georeferenced extents of output file. The values must be expressed in georeferenced units. If not specified, the extent of the output is the minimum bounding box of the set of source rasters. Pixels within the extent of the output but not covered by a source raster will be read as valid pixels with a value of zero unless a NODATA value is specified using --output-nodata.

    --hide-nodata
        Even if any band contains nodata value, giving this option makes the output band not report the NoData. Useful when you want to control the background color of the dataset.

    --input-nodata <value>[,<value>]...
        Set nodata values for input bands (different values can be supplied for each band). If the option is not specified, the intrinsic nodata settings on the source datasets will be used (if they exist). The value set by this option is written in the NODATA element of each ComplexSource element.

    --output-nodata <value>[,<value>]...
        Set nodata values at the output band level (different values can be supplied for each band). If more than one value is supplied, all values should be quoted to keep them together as a single operating system argument. If the option is not specified, intrinsic nodata settings on the first dataset will be used (if they exist). The value set by this option is written in the NoDataValue element of each VRTRasterBand element. Use a value of None to ignore intrinsic nodata settings on the source datasets.

    --resolution {<xres,yres>|same|highest|lowest|average}
        In case the resolution of all input files is not the same, the --resolution flag enables the user to control the way the output resolution is computed.

        same, the default, checks that all source rasters have the same resolution and errors out when this is not the case.

        highest will pick the smallest values of pixel dimensions within the set of source rasters.

        lowest will pick the largest values of pixel dimensions within the set of source rasters.

        average will compute an average of pixel dimensions within the set of source rasters.

        common determines the greatest common divisor of the source pixel dimensions, e.g. 0.2 for source pixel dimensions of 0.4 and 0.6.

        <xres>,<yres>. The values must be expressed in georeferenced units. Both must be positive values.

    --target-aligned-pixels
        (target aligned pixels) align the coordinates of the extent of the output file to the values of the --resolution, such that the aligned extent includes the minimum extent. Alignment means that xmin / resx, ymin / resy, xmax / resx and ymax / resy are integer values.

STANDARD OPTIONS

    --append
        Append input raster as a new subdataset to an existing output file. Only works with drivers that support adding subdatasets such as GTiff -- GeoTIFF File Format and GPKG -- GeoPackage raster This also creates the output dataset if it does not exist yet.

    --co, --creation-option <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.

    --if, --input-format <format>
        Format/driver name to be attempted to open the input file(s). It is generally not necessary to specify it, but it can be used to skip automatic driver detection, when it fails to select the appropriate driver. This option can be repeated several times to specify several candidate drivers. Note that it does not force those drivers to open the dataset. In particular, some drivers have requirements on file extensions.

        May be repeated.

    --oo, --open-option <NAME>=<VALUE>
        Dataset open option (format specific).

        May be repeated.

    -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

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

RETURN STATUS CODE

The program returns status code 0 in case of success, and non-zero in case of error (non-blocking errors emitted as warnings are considered as a successful execution).

EXAMPLES

  Example 1: Make a RGB stack from 3 single-band input files

            gdal raster stack red.tif green.tif blue.tif rgb.tif

  Example 2: Make a virtual (VRT) stack from 2 single-band input files

            gdal raster stack raster1.tif raster2.tif result.vrt

AUTHOR
Even Rouault <even.rouault@spatialys.com>

COPYRIGHT
1998-2026