- testing 3.12.3+dfsg-1
- unstable 3.12.3+dfsg-1
- experimental 3.13.0~beta1+dfsg-1~exp1
| GDAL-RASTER-SELECT(1) | GDAL | GDAL-RASTER-SELECT(1) |
NAME¶
gdal-raster-select - Select a subset of bands from a raster dataset
Added in version 3.11.
SYNOPSIS¶
Usage: gdal raster select [OPTIONS] <INPUT> <OUTPUT> <BAND> Select a subset of bands from a raster dataset. Positional arguments:
-i, --input <INPUT> Input raster datasets [required]
-o, --output <OUTPUT> Output raster dataset [required]
-b, --band <BAND> Band(s) (1-based index, 'mask', 'mask:<band>' or color interpretation such as 'red') [1.. values] [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 or warning message) 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 dataset is allowed
Mutually exclusive with --append
--append Append as a subdataset to existing output
Mutually exclusive with --overwrite
--exclude Exclude specified bands
--mask <MASK> Mask band (1-based index, 'mask', 'mask:<band>' or 'none') 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 select can be used to select and re-order a subset of raster bands from a raster dataset.
This subcommand is also available as a potential 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¶
- --exclude
- Added in version 3.13.
Modifies the behavior of the algorithm such that all bands are selected, except the ones mentioned by --band.
- --band <BAND>
- Select one or several input bands. Bands are numbered from 1. Multiple
values may be selected to select a set of input bands to write to the
output file, or to reorder bands. The special value mask means the
mask band of the first band of the input dataset. The mask band of any
band can be specified with mask:<band>. A mask band selected
with --band will become an ordinary band in the output dataset.
Starting with GDAL 3.13, <BAND> can also be a color interpretation such as "red", "green", "blue", "alpha", "nir", etc.
- --mask <BAND>
- Select one input band to create output dataset mask band.. Bands are numbered from 1. The special value mask means the mask band of the first band of the input dataset. The mask band of any band can be specified with mask:<band>. <BAND> can be set to none to avoid copying the global mask of the input dataset if it exists. Otherwise it is copied by default, unless the mask is an alpha channel, or if it is explicitly selected to be a regular band of the output dataset (--band mask)
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: Reorder a 3-band dataset with bands ordered Blue, Green, Red to Red, Green, Blue¶
$ gdal raster select --band 3,2,1 bgr.tif rgb.tif --overwrite
Example 2: Select input bands by their color interpretation¶
$ gdal raster select --band red,green,blue input.tif rgb.tif --overwrite
Example 3: Convert a RGBA dataset to a YCbCR JPEG compressed GeoTIFF¶
$ gdal raster select --band 1,2,3 --mask 4 --co COMPRESS=JPEG,PHOTOMETRIC=YCBCR rgba.tif rgb_mask.tif
AUTHOR¶
Even Rouault <even.rouault@spatialys.com>
COPYRIGHT¶
1998-2026
| April 15, 2026 |