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 at 1) of the band to which the scaling must be only applied. πŸ“
  • --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 --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. 😭 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 as GTiff β€” GeoTIFF File Format and GPKG β€” 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 by gdal --formats | grep raster | grep rw | sort. no cap, that's literally the command. ✨
  • --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.
bestie I am quoting this list character for character as the docs give it, and the synopsis up top lists it a lil differently (UInt8 and a Float16 in 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, gdal errors 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 🫢


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