GDAL-RASTER-SELECT(1) GDAL GDAL-RASTER-SELECT(1)
gdal-raster-select - Select a subset of bands from a raster dataset
Added in version 3.11.
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' or 'mask:<band>') [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)
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
--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]
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
-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, --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.
--overwrite
Allow program to overwrite existing target file or dataset.
Otherwise, by default, gdal errors out if the target file or
dataset already exists.
--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.
--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)
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.
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: 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
Even Rouault <even.rouault@spatialys.com>
1998-2026
March 20, 2026 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' or 'mask:<band>') [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)
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
--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
Standard options
-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, --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.
--overwrite
Allow program to overwrite existing target file or dataset.
Otherwise, by default, gdal errors out if the target file or
dataset already exists.
--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.
--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)
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.
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: 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
March 20, 2026 GDAL-RASTER-SELECT(1)