Skip to main content

BandArithmetic

Summary

Performs an arithmetic operation on the bands of a multiband raster object and returns a raster object with the operation applied.

Discussion

For more information about the methods and band orders used with this function, see the Band Arithmetic raster function.

The referenced raster dataset for the raster object is temporary. To make it permanent, you can call the raster object's save method.

Syntax

BandArithmetic(raster, band_ids, {method})

Parameter Explanation Data Type

raster

The input raster.

Raster

band_ids

The band IDs to use in the arithmetic operation, separated by a space. Band IDs are indexed using one-based indexing, so that the first band in a list of bands in a multiband raster object has an index of 1.

The bands should be provided in the order that is required by the arithmetic method. For information about the order of bands needed for each method, see Band Arithmetic.

String

method

The arithmetic operation to apply to the bands.

A custom operation can also be defined.

  • 1—NDVI

  • 2—SAVI

  • 3—TSAVI

  • 4—MSAVI

  • 5—GEMI

  • 6—PVI

  • 7—GVITM

  • 8—Sultan

  • 9—VARI

  • 10—GNDVI

  • 11—SR

  • 12—NDVIre

  • 13—SRre

  • 14—MTVI2

  • 15—RTVICore

  • 16—CIre

  • 17—CIg

  • 18—NDWI

  • 19—EVI

  • 20—Iron oxide

  • 21—Ferrous minerals

  • 22—Clay minerals

  • 23—WNDWI

The default value is 1.

Integer

Return value

Data Type Explanation

Raster

The output raster object with the band arithmetic applied.

Code sample

BandArithmetic example 1

Calculates the Simple Ratio (SR) for a Landsat 8 image.

import arcpy

SimpleRatio = arcpy.ia.BandArithmetic("Landsat8.tif","5 4", 11)
BandArithmetic example 2

Calculates a custom operator for a Landsat 8 image.

import arcpy

BandAddition_raster = arcpy.ia.BandArithmetic("Landsat8.tif","B2+B3", 0)