.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "GDAL-RASTER-SCALE" "1" "Nov 07, 2025" "" "GDAL" .SH NAME gdal-raster-scale \- Scale the values of the bands of a raster dataset .sp Added in version 3.11. .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .EX Usage: gdal raster scale [OPTIONS] Scale the values of the bands of a raster dataset. Positional arguments: \-i, \-\-input Input raster datasets [required] \-o, \-\-output Output raster dataset [required] 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) Options: \-f, \-\-of, \-\-format, \-\-output\-format Output format (\(dqGDALG\(dq allowed) \-\-co, \-\-creation\-option = 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=Byte|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) \-\-src\-min Minimum value of the source range \-\-src\-max Maximum value of the source range \-\-dst\-min Minimum value of the destination range \-\-dst\-max Maximum value of the destination range \-\-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 formats [may be repeated] \-\-oo, \-\-open\-option = Open options [may be repeated] .EE .UNINDENT .UNINDENT .SH DESCRIPTION .sp \fBgdal raster scale\fP can be used to rescale the input pixels values from the range \fI\%\-\-src\-min\fP to \fI\%\-\-src\-max\fP to the range \fI\%\-\-dst\-min\fP to \fI\%\-\-dst\-max\fP\&. It is also often necessary to reset the output datatype with the \fI\%\-\-ot\fP 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 \fBgdal raster edit \-\-stats {source_dataset}\fP priorly to precompute statistics, for formats that support serializing statistics computations (GeoTIFF, VRT...) Source values are clipped to the range defined by \fBsrcmin\fP and \fBsrcmax\fP, unless \fI\%\-\-no\-clip\fP is set. .sp By default, the scaling is applied to all bands. It is possible to restrict it to a single band with \fI\%\-\-band\fP and leave values of other bands unmodified. .sp This command is the reverse operation of \fI\%gdal raster unscale\fP\&. .sp This subcommand is also available as a potential step of \fI\%gdal raster pipeline\fP .SS Standard options .INDENT 0.0 .TP .B \-f, \-\-of, \-\-format, \-\-output\-format Which output raster format to use. Allowed values may be given by \fBgdal \-\-formats | grep raster | grep rw | sort\fP .UNINDENT .INDENT 0.0 .TP .B \-\-co = 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. .sp May be repeated. .sp 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 \fI\%\-\-formats\fP command line option but the documentation for the format is the definitive source of information on driver creation options. See \fI\%Raster drivers\fP format specific documentation for legal creation options for each format. .UNINDENT .INDENT 0.0 .TP .B \-\-overwrite Allow program to overwrite existing target file or dataset. Otherwise, by default, \fBgdal\fP errors out if the target file or dataset already exists. .UNINDENT .INDENT 0.0 .TP .B \-\-ot, \-\-datatype, \-\-output\-data\-type Output data type among \fBByte\fP, \fBInt8\fP, \fBUInt16\fP, \fBInt16\fP, \fBUInt32\fP, \fBInt32\fP, \fBUInt64\fP, \fBInt64\fP, \fBCInt16\fP, \fBCInt32\fP, \fBFloat32\fP, \fBFloat64\fP, \fBCFloat32\fP, \fBCFloat64\fP\&. .UNINDENT .INDENT 0.0 .TP .B \-b, \-\-band Index (starting at 1) of the band to which the scaling must be only applied. .UNINDENT .INDENT 0.0 .TP .B \-\-src\-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 \fI\%\-\-src\-max\fP\&. .UNINDENT .INDENT 0.0 .TP .B \-\-src\-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 \fI\%\-\-src\-min\fP\&. .UNINDENT .INDENT 0.0 .TP .B \-\-dst\-min Minimum value of the output range. This option must be used together with \fI\%\-\-dst\-max\fP\&. .UNINDENT .INDENT 0.0 .TP .B \-\-dst\-max Maximum value of the output range. This option must be used together with \fI\%\-\-dst\-min\fP\&. .UNINDENT .INDENT 0.0 .TP .B \-\-exponent Apply non\-linear scaling with a power function. \fBexp_val\fP is the exponent of the power function (must be positive). This option must be used with the \fI\%\-\-src\-min\fP / \fI\%\-\-src\-max\fP / \fI\%\-\-dst\-min\fP / \fI\%\-\-dst\-max\fP options. .sp The scaled value \fBDst\fP is calculated from the source value \fBSrc\fP with the following formula: .sp .ce {Dst} = \eleft( {Dst}_{max} \- {Dst}_{min} \eright) \etimes \eoperatorname{max} \eleft( 0, \eoperatorname{min} \eleft( 1, \eleft( \efrac{{Src} \- {Src}_{min}}{{Src}_{max}\-{Src}_{min}} \eright)^{exp\e_val} \eright) \eright) + {Dst}_{min} .ce 0 .sp \fBNOTE:\fP .INDENT 7.0 .INDENT 3.5 \fI\%gdal raster unscale\fP assumes linear scaling, and this cannot unscale values back to the original ones. .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B \-\-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. .UNINDENT .SH GDALG OUTPUT (ON-THE-FLY / STREAMED DATASET) .sp This program supports serializing the command line as a JSON file using the \fBGDALG\fP output format. The resulting file can then be opened as a raster dataset using the \fI\%GDALG: GDAL Streamed Algorithm\fP driver, and apply the specified pipeline in a on\-the\-fly / streamed way. .SH EXAMPLES .SS Example 1: Rescale linearly values of a UInt16 dataset from [0,4095] to a Byte dataset [0,255] .INDENT 0.0 .INDENT 3.5 .sp .EX $ gdal raster scale \-\-datatype Byte \-\-src\-min 0 \-\-src\-max 4095 uint16.tif byte.tif \-\-overwrite .EE .UNINDENT .UNINDENT .SH AUTHOR Even Rouault .SH COPYRIGHT 1998-2025 .\" Generated by docutils manpage writer. .