# How Raster Calculator works

The Raster Calculator tool allows you to create and execute Map Algebra expressions in a tool. Like other geoprocessing tools, the Raster Calculator can be used in ModelBuilder, allowing the power of Map Algebra to be more easily integrated into your workflows.

The Raster Calculator tool is not intended to be used in scripting environments and is not available in the standard Spatial Analyst arcpy module. To learn more about scripting and Map Algebra, see the help topic What is Map Algebra?

The Raster Calculator is specifically designed to offer the following benefits:

- Implement single-line algebraic expressions.
- Support the use of variables in Map Algebra when in ModelBuilder.
- Apply Spatial Analyst operators on three or more inputs in a single expression.
- Use multiple Spatial Analyst tools in a single expression.

Raster Calculator is designed to execute a single-line algebraic expression using multiple tools and operators using a simple, calculator-like tool interface. When multiple tools or operators are used in one expression, the performance of this equation will generally be faster then executing each of the operators or tools individually.

## Using the Raster Calculator tool

There are four main areas in the tool dialog box that are used to create a Map Algebra expression:

### Layers and variables

The input Layers and variables list identifies the input that can be used in the Map Algebra expression. If you are using the tool standing alone, the list will contain the layers in the table of contents. When the tool is used in ModelBuilder, the list will contain the layers in the table of contents, outputs created in the model, and other model variables.

### Calculator and operator buttons

The calculator buttons allow you to enter numeric values into the expression. The operator buttons allow you to enter mathematical (addition, division, and so on) and logical (greater than, equal to, and so forth) operators into the expression. By clicking any of these buttons, that number or operator will be entered into the expression where the cursor is currently positioned. Take care to ensure that the expression follows the rules for correct Map Algebra syntax rules.

### Tools

The tool list is a convenient selection of tools that can be used in the Map Algebra expression. By clicking a tool in the list, the tool name and open and close parentheses [()] will be placed in the expression where the cursor is currently positioned. The remaining input required by the tool must then be entered. A tool can be placed anywhere in the expression, but it should be placed in a position that produces valid Map Algebra syntax.

### Expression

The expression is the Map Algebra expression to be executed. The expression must be entered with valid syntax. See the section below to learn more about the syntax rules for Map Algebra.

## The Map Algebra language

Map Algebra is a simple and powerful algebra with which you can execute all Spatial Analyst tools, operators, and functions to perform geographic analysis.

The Map Algebra used in Raster Calculator has a syntax, or a set of rules, that must be followed to create a valid expression. If these rules are not adhered to, the expression may be invalid and will not execute, or you may get results you did not expect.

Not only can Map Algebra be accessed from the Raster Calculator tool, it can also be accessed in Python scripting using the Spatial Analyst module. The Map Algebra syntax used in this tool is the same, with the following exceptions:

- You do not need to put the output raster name or the equal sign (=) in the expression, since the output name is specified in the Output raster parameter.
- You do not need to cast input data as a Raster object when using operators.

For more information on Map Algebra, see the following: