.\" 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-CALC" "1" "May 06, 2025" "" "GDAL" .SH NAME gdal-raster-calc \- Perform pixel-wise calculations on a raster .sp Added in version 3.11. .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .EX Usage: gdal raster calc [OPTIONS] [] Perform raster algebra Positional arguments: \-i, \-\-input Input raster datasets [1.. values] \-o, \-\-output Output raster dataset (created by algorithm) [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] \-\-progress Display 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 \-\-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 \-\-no\-check\-srs Do not check consistency of input spatial reference systems \-\-no\-check\-extent Do not check consistency of input extents \-\-calc Expression(s) to evaluate [1.. values] [required] .EE .UNINDENT .UNINDENT .SH DESCRIPTION .sp \fBgdal raster calc\fP performs pixel\-wise calculations on one or more input GDAL datasets. Calculations can be performed eagerly, writing results to a conventional raster format, or lazily, written as a set of derived bands in a \fI\%VRT (Virtual Dataset)\fP\&. .sp The list of input GDAL datasets can be specified at the end of the command line or put in a text file (one input per line) for very long lists. If more than one input dataset is used, it should be prefixed with a name by which it will be referenced in the calculation, e.g. \fBA=my_data.tif\fP\&. (If a single dataset is used, it will be referred to with the variable \fBX\fP in formulas.) .sp The inputs should have the same spatial reference system and should cover the same spatial extent but are not required to have the same spatial resolution. The spatial extent check can be disabled with \fI\%\-\-no\-check\-extent\fP, in which case the inputs must have the same dimensions. The spatial reference system check can be disabled with \fI\%\-\-no\-check\-srs\fP\&. .sp The following options are available: .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 \-i [=] Select an input dataset to be processed. If more than one input dataset is provided, each dataset must be prefixed with a name to which it will will be referenced in \fI\%\-\-calc\fP\&. .UNINDENT .INDENT 0.0 .TP .B \-\-calc An expression to be evaluated using the \X'tty: link https://beltoforion.de/en/muparser'\fI\%muparser\fP\X'tty: link' math parser library. The expression may refer to individual bands of each input (e.g., \fBX[1] + 3\fP) or it may be applied to all bands of an input (\fBX + 3\fP). If the expression contains a reference to all bands of multiple inputs, those inputs must either have the same the number of bands, or a single band. .sp For example, if inputs \fBA\fP and \fBB\fP each have three bands, and input \fBC\fP has a single band, then the argument \fB\-\-calc \(dqA + B + C\(dq\fP is equivalent to \fB\-\-calc \(dqA[1] + B[1] + C[1]\(dq \-\-calc \(dqA[2] + B[2] + C[1]\(dq \-\-calc \(dqA[3] + B[3] + C[1]\(dq\fP\&. .sp Multiple calculations may be specified; output band(s) will be produced for each expression in the order they are provided. .sp Input rasters will be converted to 64\-bit floating point numbers before performing calculations. .UNINDENT .INDENT 0.0 .TP .B \-\-no\-check\-extent Do not verify that the input rasters have the same spatial extent. The input rasters will instead be required to have the same dimensions. The geotransform of the first input will be assigned to the output. .UNINDENT .INDENT 0.0 .TP .B \-\-no\-check\-srs Do not check the spatial reference systems of the inputs for consistency. All inputs will be assumed to have the spatial reference system of the first input, and this spatial reference system will be used for the output. .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: Per\-band sum of three files .INDENT 0.0 .INDENT 3.5 .sp .EX gdal raster calc \-i \(dqA=file1.tif\(dq \-i \(dqB=file2.tif\(dq \-i \(dqC=file3.tif\(dq \-\-calc \(dqA+B+C\(dq \-o out.tif .EE .UNINDENT .UNINDENT .SS Example 2: Per\-band maximum of three files .INDENT 0.0 .INDENT 3.5 .sp .EX gdal raster calc \-i \(dqA=file1.tif\(dq \-i \(dqB=file2.tif\(dq \-i \(dqC=file3.tif\(dq \-\-calc \(dqmax(A,B,C)\(dq \-o out.tif .EE .UNINDENT .UNINDENT .SS Example 3: Setting values of zero and below to NaN .INDENT 0.0 .INDENT 3.5 .sp .EX gdal raster calc \-i \(dqA=input.tif\(dq \-o result.tif \-\-calc=\(dqA > 0 ? A : NaN\(dq .EE .UNINDENT .UNINDENT .SH AUTHOR Dan Baston .SH COPYRIGHT 1998-2025 .\" Generated by docutils manpage writer. .