GDAL-RASTER-SCALE(1) GDAL 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]
Scale the values of the bands of a raster dataset.
Positional arguments:
-i, --input Input raster datasets [required] [not available in pipelines]
-o, --output Output raster dataset [required] [not available in pipelines]
Common Options:
-h, --help Display help message and exit
--json-usage Display usage as JSON document and exit
--config = 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 ("GDALG" allowed) [not available in pipelines]
--co, --creation-option = 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
--ot, --datatype, --output-data-type Output data type. OUTPUT-DATA-TYPE=UInt8|Int8|UInt16|Int16|UInt32|Int32|UInt64|Int64|CInt16|CInt32|Float16|Float32|Float64|CFloat32|CFloat64
-b, --band Select band to restrict the scaling (1-based index)
--input-min Minimum value of the source range
Depends on --input-max
--input-max Maximum value of the source range
Depends on --input-min
--output-min Minimum value of the destination range
Depends on --output-max
--output-max Maximum value of the destination range
Depends on --output-min
--exponent Exponent to apply non-linear scaling with a power function
--no-clip Do not clip input values to [innput-min, input-max]
Advanced Options:
--if, --input-format Input formats [may be repeated] [not available in pipelines]
--oo, --open-option = Open options [may be repeated] [not available in pipelines]
DESCRIPTION
gdal raster scale can be used to rescale the input pixels values from
the range --input-min to --input-max to the range --output-min to
--output-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
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
-b, --band
Index (starting at 1) of the band to which the scaling must be
only applied.
--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 --input-min / --input-max / --output-min /
--output-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.
--input-max
Maximum value of the source range. If not specified, it will be
calculated from the source dataset. This option must be used
together with --input-min.
--input-min
Minimum value of the source range. If not specified, it will be
calculated from the input dataset. This option must be used
together with --input-max.
--output-max
Maximum value of the output range. This option must be used
together with --output-min.
--output-min
Minimum value of the output range. This option must be used
together with --output-max.
--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.
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 =
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/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 =
Dataset open option (format specific).
May be repeated.
-f, --of, --format, --output-format
Which output raster format to use. Allowed values may be given
by gdal --formats | grep raster | grep rw | sort
--ot, --datatype, --output-data-type
Output data type among Byte, Int8, UInt16, Int16, UInt32, Int32,
UInt64, Int64, CInt16, CInt32, Float32, Float64, CFloat32,
CFloat64.
--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: Rescale linearly values of a UInt16 dataset from [0,4095] to a
Byte dataset [0,255]
$ gdal raster scale --datatype Byte --input-min 0 --input-max 4095 uint16.tif byte.tif --overwrite
AUTHOR
Even Rouault
COPYRIGHT
1998-2026
August 18, 2026 GDAL-RASTER-SCALE(1)