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 asxmin,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 from1. If input bands aren't set, all bands get added to the output. You can use multiple-bswitches 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 theNODATAelement of eachComplexSourceelement. ๐ณ๏ธ--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 theNoDataValueelement of eachVRTRasterBandelement. Use a value ofNoneto 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--resolutionflag 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.highestwill pick the smallest values of pixel dimensions within the set of source rasters.lowestwill pick the largest values of pixel dimensions within the set of source rasters.averagewill compute an average of pixel dimensions within the set of source rasters.commondetermines the greatest common divisor of the source pixel dimensions, e.g.0.2for source pixel dimensions of0.4and0.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 thatxmin / resx,ymin / resy,xmax / resxandymax / resyare 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--formatscommand 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 bygdal --formats | grep raster | grep rw | sort๐--overwriteโ allow the program to overwrite an existing target file or dataset. Otherwise, by default,gdalerrors 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>
๐ COPYRIGHT ๐
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
- alpine 3.24: gdal-doc 3.13.3-r0 ยท MIT
- arch rolling: gdal 3.13.3-6 ยท MIT
- ubuntu stonking: gdal-bin 3.13.3+dfsg-1ubuntu4 ยท MIT
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms