Arithmetic

Résumé

Performs an arithmetic operation between two rasters or between a raster and a scalar and returns a raster object with the operation applied.

Discussion

For more information about how this function works, see the Arithmetic raster function.

Syntaxe

Arithmetic (raster1, raster2, {operation_type}, {extent_type}, {cellsize_type})
ParamètreExplicationType de données
raster1

The first input raster. This can be a scalar raster where all pixels have the same value.

Raster
raster2

The second input raster. This can be a scalar raster where all pixels have the same value.

Raster
operation_type

The arithmetic operation to apply between the two input rasters.

  • DivideOutputs the divisible result between the corresponding pixel values for each raster.
  • MinusOutputs the difference between the corresponding pixel values for each raster. This operation can be used to calculate change detection.
  • ModeOutputs the pixel value of all overlapping pixels that occurs the most. For example, if there are six bands in a raster, there will be six overlapping pixels. For the values 4, 5, 6, 4, 7, 9, the mode value is 4.
  • MultiplyOutputs the product of the corresponding pixel values for each raster. This operation can be used to perform some cost functions.
  • PlusOutputs the sum of all the corresponding pixel values for each raster.
  • PowerOutputs the product of the corresponding pixel values raised to the power of the input raster or scalar.

(La valeur par défaut est Plus)

String
extent_type

The method to use to compute the extent of the output when the input rasters have different extents.

  • FirstOfThe output extent is defined using the extent of the first input raster.
  • LastOfThe output extent is defined using the extent of the last input raster.
  • IntersectionOfThe output extent is defined as the intersecting area of the input rasters.
  • UnionOfThe output extent is defined as the total extent of the input rasters.

(La valeur par défaut est FirstOf)

String
cellsize_type

The method to use to compute the cell size of the output when the input rasters have different cell sizes.

  • FirstOfThe output cell size is defined using the cell size of the first input raster.
  • LastOfThe output cell size is defined using the cell size of the last input raster.
  • MaxOfThe output cell size is defined using the maximum cell size of the input rasters.
  • MeanOfThe output cell size is defined using the mean of both input rasters.
  • MinOfThe output cell size is defined using the minimum cell size of the input rasters.

(La valeur par défaut est FirstOf)

String
Valeur renvoyée
Type de donnéesExplication
Raster

The output raster with the arithmetic operation applied.

Exemple de code

Arithmetic example

Multiplies two rasters and uses the total extent of the inputs.

import arcpy

new_raster = arcpy.ia.Arithmetic("Raster1.tif","Raster2.tif", "Multiply", "UnionOf", "FirstOf")