# RasterCalculator

Image Analyst ライセンスで利用できます。

Spatial Analyst のライセンスで利用可能。

## 概要

Provides access to all existing math functions and returns a raster object with the mathematical operation applied.

## ディスカッション

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

## 構文

RasterCalculator (rasters, input_names, expression, {extent_type}, {cellsize_type})
 パラメーター 説明 データ タイプ rasters[rasters,...] The list of input rasters. Raster input_names[input_names,...] The user-defined variable names. String expression Build an algebraic expression to perform spatial analysis on the input raster. String extent_type The spatial extent used to create the output raster.FirstOf —The extent of the first raster variableIntersectionOf —The minimum area common to all input rastersUnionOf —The combined extent of all input rastersLastOf —The extent of the last raster variable(デフォルト値は次のとおりです FirstOf) String cellsize_type The cell size used to create the output raster.FirstOf —The cell size of the first raster variableMinOf —The minimum cell size of the input rastersMaxOf —The maximum cell size of the input rastersMeanOf —The average cell size of the input rastersLastOf —The cell size of the last raster variable(デフォルト値は次のとおりです FirstOf) String

 データ タイプ 説明 Raster The output raster.

## コードのサンプル

RasterCalculator example 1

Example of a map algebraic expression using a raster calculator.

from arcpy.sa import *
out_rc_multi_raster = RasterCalculator(["raster1.tif", "raster2.tif"],
["x", "y"], "x*y")
out_rc_multi_raster.save("C:/arcpyExamples/raster_rc_multi.tif")
RasterCalculator example 2

Example of a map algebraic expression using a raster calculator.

# Import system modules
import arcpy
from arcpy.sa import *

# Check out the Spatial Analyst extension license
arcpy.checkOutExtension("Spatial")

# Set the analysis environments
arcpy.env.workspace = "C:/arcpyExamples/data"

# Set local variables
in_raster1 = "raster1.tif"
in_raster2 = "raster2.tif"

# Excuate RasterCalculator(Minus) function
out_rc_minus_raster = RasterCalculator([in_raster1, in_raster2], ["x", "y"],
"x-y", "", "FirstOf")

# Save the output
out_rc_minus_raster.save("C:/arcpyExamples/raster_rc_minus.tif")

#### 関連トピック

##### 関連トピック
1. An overview of the Spatial Analyst functions