GDAL-RASTER-SCALE(1) GDAL GDAL-RASTER-SCALE(1)
gdal-raster-scale - Scale the values of the bands of a raster dataset
Added in version 3.11.
Usage: gdal raster scale [OPTIONS] <INPUT> <OUTPUT>
Scale the values of the bands of a raster dataset.
Positional arguments:
-i, --input <INPUT> Input raster datasets [required]
-o, --output <OUTPUT> Output raster dataset [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
--ot, --datatype, --output-data-type <OUTPUT-DATA-TYPE> Output data type. OUTPUT-DATA-TYPE=Byte|Int8|UInt16|Int16|UInt32|Int32|UInt64|Int64|CInt16|CInt32|Float16|Float32|Float64|CFloat32|CFloat64
-b, --band <BAND> Select band to restrict the scaling (1-based index)
--src-min <SRC-MIN> Minimum value of the source range
--src-max <SRC-MAX> Maximum value of the source range
--dst-min <DST-MIN> Minimum value of the destination range
--dst-max <DST-MAX> Maximum value of the destination range
--exponent <EXPONENT> Exponent to apply non-linear scaling with a power function
--no-clip Do not clip input values to [srcmin, srcmax]
Advanced Options:
--if, --input-format <INPUT-FORMAT> Input formats [may be repeated]
--oo, --open-option <KEY>=<VALUE> Open options [may be repeated]
gdal raster scale can be used to rescale the input pixels values from
the range --src-min to --src-max to the range --dst-min to --dst-max.
It is also often necessary to reset the output datatype with the --ot
switch. If omitted the output range is from the minimum value to the
maximum value allowed for integer data types (for example from 0 to
255 for Byte output) or from 0 to 1 for floating-point data types.
If omitted the input range is automatically computed from the source
dataset. This may be a slow operation on a large source dataset, and
if using it multiple times for several gdal_translate invocation, it
might be beneficial to call gdal raster edit --stats {source_dataset}
priorly to precompute statistics, for formats that support
serializing statistics computations (GeoTIFF, VRT...) Source values
are clipped to the range defined by srcmin and srcmax, unless
--no-clip is set.
By default, the scaling is applied to all bands. It is possible to
restrict it to a single band with --band and leave values of other
bands unmodified.
This command is the reverse operation of gdal raster unscale.
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.
--ot, --datatype, --output-data-type <OUTPUT-DATA-TYPE>
Output data type among Byte, Int8, UInt16, Int16, UInt32,
Int32, UInt64, Int64, CInt16, CInt32, Float32, Float64,
CFloat32, CFloat64.
-b, --band <BAND>
Index (starting at 1) of the band to which the scaling must be
only applied.
--src-min <SRCMIN>
Minimum value of the source range. If not specified, it will
be calculated from the input dataset. This option must be
used together with --src-max.
--src-max <SRCMAX>
Maximum value of the source range. If not specified, it will
be calculated from the source dataset. This option must be
used together with --src-min.
--dst-min <DSTMIN>
Minimum value of the output range. This option must be used
together with --dst-max.
--dst-max <DSTMAX>
Maximum value of the output range. This option must be used
together with --dst-min.
--exponent <EXPONENT>
Apply non-linear scaling with a power function. exp_val is the
exponent of the power function (must be positive). This option
must be used with the --src-min / --src-max / --dst-min /
--dst-max options.
The scaled value Dst is calculated from the source value Src
with the following formula:
{Dst} = \left( {Dst}_{max} - {Dst}_{min} \right) \times
\operatorname{max} \left( 0, \operatorname{min} \left( 1,
\left( \frac{{Src} - {Src}_{min}}{{Src}_{max}-{Src}_{min}}
\right)^{exp\_val} \right) \right) + {Dst}_{min}
NOTE:
gdal raster unscale assumes linear scaling, and this cannot
unscale values back to the original ones.
--no-clip
Disable clipping input values to the source range. Note that
using this option with non-linear scaling with a non-integer
exponent will cause input values lower than the minimum value
of the source range to be mapped to not-a-number.
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: Rescale linearly values of a UInt16 dataset from [0,4095] to a
Byte dataset [0,255]
$ gdal raster scale --datatype Byte --src-min 0 --src-max 4095 uint16.tif byte.tif --overwrite
Even Rouault <even.rouault@spatialys.com>
1998-2026
March 20, 2026 GDAL-RASTER-SCALE(1)
NAME
gdal-raster-scale - Scale the values of the bands of a raster dataset
Added in version 3.11.
SYNOPSIS
Usage: gdal raster scale [OPTIONS] <INPUT> <OUTPUT>
Scale the values of the bands of a raster dataset.
Positional arguments:
-i, --input <INPUT> Input raster datasets [required]
-o, --output <OUTPUT> Output raster dataset [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
--ot, --datatype, --output-data-type <OUTPUT-DATA-TYPE> Output data type. OUTPUT-DATA-TYPE=Byte|Int8|UInt16|Int16|UInt32|Int32|UInt64|Int64|CInt16|CInt32|Float16|Float32|Float64|CFloat32|CFloat64
-b, --band <BAND> Select band to restrict the scaling (1-based index)
--src-min <SRC-MIN> Minimum value of the source range
--src-max <SRC-MAX> Maximum value of the source range
--dst-min <DST-MIN> Minimum value of the destination range
--dst-max <DST-MAX> Maximum value of the destination range
--exponent <EXPONENT> Exponent to apply non-linear scaling with a power function
--no-clip Do not clip input values to [srcmin, srcmax]
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 scale can be used to rescale the input pixels values from
the range --src-min to --src-max to the range --dst-min to --dst-max.
It is also often necessary to reset the output datatype with the --ot
switch. If omitted the output range is from the minimum value to the
maximum value allowed for integer data types (for example from 0 to
255 for Byte output) or from 0 to 1 for floating-point data types.
If omitted the input range is automatically computed from the source
dataset. This may be a slow operation on a large source dataset, and
if using it multiple times for several gdal_translate invocation, it
might be beneficial to call gdal raster edit --stats {source_dataset}
priorly to precompute statistics, for formats that support
serializing statistics computations (GeoTIFF, VRT...) Source values
are clipped to the range defined by srcmin and srcmax, unless
--no-clip is set.
By default, the scaling is applied to all bands. It is possible to
restrict it to a single band with --band and leave values of other
bands unmodified.
This command is the reverse operation of gdal raster unscale.
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.
--ot, --datatype, --output-data-type <OUTPUT-DATA-TYPE>
Output data type among Byte, Int8, UInt16, Int16, UInt32,
Int32, UInt64, Int64, CInt16, CInt32, Float32, Float64,
CFloat32, CFloat64.
-b, --band <BAND>
Index (starting at 1) of the band to which the scaling must be
only applied.
--src-min <SRCMIN>
Minimum value of the source range. If not specified, it will
be calculated from the input dataset. This option must be
used together with --src-max.
--src-max <SRCMAX>
Maximum value of the source range. If not specified, it will
be calculated from the source dataset. This option must be
used together with --src-min.
--dst-min <DSTMIN>
Minimum value of the output range. This option must be used
together with --dst-max.
--dst-max <DSTMAX>
Maximum value of the output range. This option must be used
together with --dst-min.
--exponent <EXPONENT>
Apply non-linear scaling with a power function. exp_val is the
exponent of the power function (must be positive). This option
must be used with the --src-min / --src-max / --dst-min /
--dst-max options.
The scaled value Dst is calculated from the source value Src
with the following formula:
{Dst} = \left( {Dst}_{max} - {Dst}_{min} \right) \times
\operatorname{max} \left( 0, \operatorname{min} \left( 1,
\left( \frac{{Src} - {Src}_{min}}{{Src}_{max}-{Src}_{min}}
\right)^{exp\_val} \right) \right) + {Dst}_{min}
NOTE:
gdal raster unscale assumes linear scaling, and this cannot
unscale values back to the original ones.
--no-clip
Disable clipping input values to the source range. Note that
using this option with non-linear scaling with a non-integer
exponent will cause input values lower than the minimum value
of the source range to be mapped to not-a-number.
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: Rescale linearly values of a UInt16 dataset from [0,4095] to a
Byte dataset [0,255]
$ gdal raster scale --datatype Byte --src-min 0 --src-max 4095 uint16.tif byte.tif --overwrite
AUTHOR
Even Rouault <even.rouault@spatialys.com>
COPYRIGHT
1998-2026
March 20, 2026 GDAL-RASTER-SCALE(1)