Arithmetic

Zusammenfassung

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

Diskussion

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

Syntax

Arithmetic (raster1, raster2, {operation_type}, {extent_type}, {cellsize_type})
ParameterErläuterungDatentyp
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.

(Der Standardwert ist 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.

(Der Standardwert ist 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.

(Der Standardwert ist FirstOf)

String
Rückgabewert
DatentypErläuterung
Raster

The output raster with the arithmetic operation applied.

Codebeispiel

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")