GDAL-RASTER-SCALE(1)
π NAME π
gdal-raster-scale β scale the values of the bands of a raster dataset. π¦
Added in version 3.11. periodt.
β¨ SYNOPSIS β¨
okay bestie, here's the whole shape of it, verbatim, no cap:
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] [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 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
--ot, --datatype, --output-data-type <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 <BAND> Select band to restrict the scaling (1-based index)
--input-min <INPUT-MIN> Minimum value of the source range
Depends on --input-max
--input-max <INPUT-MAX> Maximum value of the source range
Depends on --input-min
--output-min <OUTPUT-MIN> Minimum value of the destination range
Depends on --output-max
--output-max <OUTPUT-MAX> Maximum value of the destination range
Depends on --output-min
--exponent <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-FORMAT> Input formats [may be repeated] [not available in pipelines]
--oo, --open-option <KEY>=<VALUE> Open options [may be repeated] [not available in pipelines]
(yes, that [innput-min, input-max] is exactly how the docs spell it, I'm not touching it, it's iconic π)
πΈ DESCRIPTION πΈ
okay so gdal raster scale is the glow-up command for your pixels. It rescales the input pixel values from the range --input-min to --input-max over to the range --output-min to --output-max. slay.
bestie, you'll also often want to reset the output datatype while you're at it, and that's what the --ot switch is for. π
If you omit the output range, it goes 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 you omit the input range, it's automatically computed from the source dataset. heads up though: this may be a slow operation on a large source dataset π. And if you're 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...). iykyk. β¨
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. You can restrict it to a single band with --band and leave the values of the other bands unmodified. π
This command is the reverse operation of gdal raster unscale. and no, that's not a drill, it's literally the inverse vibe.
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. streamed. on-the-fly. main character energy honestly. π«
π PROGRAM-SPECIFIC OPTIONS π
-b,--band<BAND>β Index (starting at1) of the band to which the scaling must be only applied. π--exponent<EXPONENT>β Apply non-linear scaling with a power function.exp_valis the exponent of the power function (must be positive). This option must be used with the--input-min/--input-max/--output-min/--output-maxoptions.
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. π so if you go non-linear, there is no going home. rip.
--input-max<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<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<MAX>β Maximum value of the output range. This option must be used together with--output-min.--output-min<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. π watch out bestie.
β STANDARD OPTIONS β
--appendβ Append input raster as a new subdataset to an existing output file. Only works with drivers that support adding subdatasets such asGTiffβ GeoTIFF File Format andGPKGβ GeoPackage raster. This also creates the output dataset if it does not exist yet. π«Ά
(mutually exclusive with --overwrite, in case you were wondering π)
--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 bygdal --formats | grep raster | grep rw | sort. no cap, that's literally the command. β¨--ot,--datatype,--output-data-type<OUTPUT-DATA-TYPE>β Output data type amongByte,Int8,UInt16,Int16,UInt32,Int32,UInt64,Int64,CInt16,CInt32,Float32,Float64,CFloat32,CFloat64.
bestie I am quoting this list character for character as the docs give it, and the synopsis up top lists it a lil differently (UInt8and aFloat16in there too). I am not the one to fix it. I am simply the messenger. π
--overwriteβ Allow program to overwrite existing target file or dataset. Otherwise, by default,gdalerrors out if the target file or dataset already exists. so yes, without this you get the error, with it you get the slay π₯
(mutually exclusive with --append)
π 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
ate. no crumbs. π
π AUTHOR π
Even Rouault <even.rouault@spatialys.com> β legend behaviour honestly π«Ά
π¦ COPYRIGHT π¦
1998-2026
okay that's the whole page bestie, go scale something iconic. πβ¨ this was the GDAL manual's GDAL-RASTER-SCALE(1), dated Aug 18, 2026, and yeah that's the GDAL source + version + date sign-off, 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