GDAL-RASTER-STACK(1)

gdal-raster-stack ๐ŸŽ€

okay so hi bestie ๐Ÿ’– you've landed on GDAL-RASTER-STACK(1), one of the lil' command pages that ships with GDAL itself. sit down, grab a snack ๐Ÿ“, and let me tell you about the tool that glues a whole pile of input bands together into one multi-band output โ€” virtual (VRT) or materialized, your call.

Added in version 3.11. โœจ


๐ŸŒˆ NAME ๐ŸŒˆ

gdal-raster-stack โ€” combine together input bands into a multi-band output, either virtual (VRT) or materialized.

fr fr, that's the whole personality: take bands, stack them, ship a dataset. ๐Ÿ’…

โœจ 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. you can also hand it a @<filename> to point at 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 a 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 ๐ŸŒธ

so like. this program combines together input bands from GDAL datasets into one dataset, and that dataset can be either a virtual stack in the VRT (Virtual Dataset) format, or something more conventional like GeoTIFF. pick your fighter ๐ŸฅŠ

All bands of each input file get added as separate output bands โ€” unless you pass -b to hand-pick a subset of them. no cap.

The list of input GDAL datasets can go at the end of the command line, OR you can put it in a text file (one filename per line) when the list is absolutely unhinged-level long. ๐Ÿ“œ Wildcards '*', '?' or '[' of VSIGlob() can be used too, even on files living on network file systems like /vsis3/, /vsigs/, /vsiaz/, etc. iconic.

Starting 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. That resulting file can then be opened as a raster dataset using the GDALG: GDAL Streamed Algorithm driver, and it will apply the specified pipeline in an on-the-fly / streamed way. โœจ

lowkey the coolest trick here โ€” the command line itself becomes openable data. ๐Ÿ’…

๐Ÿ’– PROGRAM-SPECIFIC OPTIONS ๐Ÿ’–

  • --absolute-path โ€” Added in version 3.12.0. When writing a VRT file, this 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 aren't set, all bands get added to the output. You can use multiple -b switches to select a whole set of input bands. ๐ŸŽฏ
  • --bbox <xmin>,<ymin>,<xmax>,<ymax> โ€” set the georeferenced extents of the output file. The values must be expressed in georeferenced units. If you don't specify it, the extent of the output is the minimum bounding box of the set of source rasters. Pixels inside 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 a 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 isn't 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 isn't 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 isn't the same, the --resolution flag lets you control the way the output resolution gets 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. Both, bestie. positive. no negativity allowed. โญ
  • --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's generally not necessary to specify it, but it can be used to skip automatic driver detection when that 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 the program to overwrite an 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 to be a successful execution). so like, warnings are fine, actual errors are not. ๐ŸŽ€


๐Ÿ“ 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
two inputs, one .vrt, zero materialization. the virtual stack ate and left no crumbs. โœจ

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Even Rouault <even.rouault@spatialys.com>

1998-2026


and that's the whole page, bestie ๐Ÿซถ that was GDAL-RASTER-STACK(1) from the GDAL manual, dated Aug 18, 2026. go stack some bands. periodt ๐Ÿ’…๐ŸŒˆ

๐Ÿ“ฆ where this page comes from