Calc(calc,
outfile,
NoDataValue=None,
type=None,
format=None,
creation_options=None,
allBands='',
overwrite=False,
debug=False,
quiet=False,
**input_files)
| source code
|
Perform raster calculations with numpy syntax.
Use any basic arithmetic supported by numpy arrays such as +-* along with logical
operators such as >. Note that all files must have the same dimensions, but no projection checking is performed.
Keyword arguments:
[A-Z]: input files
[A_band - Z_band]: band to use for respective input file
Examples:
add two files together:
Calc("A+B", A="input1.tif", B="input2.tif", outfile="result.tif")
average of two layers:
Calc(calc="(A+B)/2", A="input1.tif", B="input2.tif", outfile="result.tif")
set values of zero and below to null:
Calc(calc="A*(A>0)", A="input.tif", A_band=2, outfile="result.tif", NoDataValue=0)
work with two bands:
Calc(["(A+B)/2", "A*(A>0)"], A="input.tif", A_band=1, B="input.tif", B_band=2, outfile="result.tif", NoDataValue=0)
|