Raster Calculator (Image Analyst)

Available with Spatial Analyst license.

Available with Image Analyst license.


Build and run a single map algebra expression using Python syntax.

Learn more about how Raster Calculator works


Raster Calculator tool in the Geoprocessing pane
Raster Calculator tool in the Geoprocessing pane with a simple expression



    The Raster Calculator tool is available for use in the application only through the Geoprocessing pane or in ModelBuilder. It is not intended for use in scripting and is not available in the ArcPy Image Analyst module.

  • The Raster Calculator tool allows you to create and run a map algebra expression that will output a raster.

  • Use the Rasters list to choose the datasets and variables to use in the expression. The Tools list provides a selection of commonly used conditional and mathematical tools, allowing you to add them to the expression. Numerical values (and mathematical operator symbols) can be added to the expression directly.

  • Full paths to data or data existing in the specified current workspace environment setting can be entered in quotes (""). Numbers and scalars can be directly entered into an expression.

  • The supported operators are listed in the following table:

  • Multiple geoprocessing tools and operations can be combined in a map algebra expression using standard Python syntax.


    When typing tool names, ensure that the tool name syntax is correct. If the capitalization is incorrect, the expression will be invalid and fail to process because Python is case sensitive.

    An example of the general format of a map algebra expression using geoprocessing tools is:

    Con(IsNull("streams"), 0, "streams")

  • The tool supports the standard map algebra syntax that is used in Python scripting. The only differences are the following:

    • You do not need to include the output raster name or the equal sign (=) in the expression because 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.

  • You can clip a raster dataset by setting the Extent environment and specifying the input raster name in the expression. When the tool runs, the resulting raster output will be clipped based on the specified extent.

  • To create a raster with cells of a constant value, specify the appropriate Extent and Cell Size environment settings and enter the numerical value into the expression.

  • When there are multiple operators in an expression, the operators are not necessarily run in left-to-right order. The operator with the highest precedence value will be run first. For more information, see the operator precedence table in Work with operators in map algebra. Use parentheses to control the run order.

  • Boolean (~, &, ^, |) operators have a higher precedence level than Relational (<, <=, >, >=, ==, !=) operators. Therefore, when Boolean operators are used in the same expression as Relational operators, the Boolean operators will be run first. To change the order in which the operators are run, use parentheses.

  • When multiple Relational or Boolean operators are used consecutively in a single expression, the expression may fail to run in some cases. To avoid, use appropriate parentheses in the expression so that the run order of the operators is explicitly defined. For more information, see Complex statement rules.

  • The performance of an operation may be enhanced by the deferred evaluation capabilities of map algebra. Deferred evaluation is an optimization technique in which individual components of an expression are intelligently processed so as to minimize the creation of intermediate datasets on disk.

    Only operators and tools that process on a per-cell basis can take advantage of this capability. Operators and tools that support deferred evaluation are included on the raster calculator tool either as a button or in the list of tools provided.

  • The Raster Calculator tool can be used in ModelBuilder, but keep the following details in mind.

    The syntax of the expression determines how variables will be specified. If you choose a variable from the variable list, it will be automatically added to the expression at the current cursor location. Upon model validation, the following occur:

    • Layer names will be enclosed in double-quote symbols ("").

      Example: "inlayer"

    • Long, double, or Boolean-type variables will be enclosed in percent symbols (%%). They do not need to be in quotes.

      Example: %scale_factor%

    • Variables representing dataset names or strings will be enclosed in both quotes and percent symbols ("%%").

      For example, inraster will become "%inraster%" in the expression.

    In ModelBuilder, the following variable types are valid inputs for an expression:

    • String
    • Boolean
    • Numeric (Double and Long)
    • Data (raster dataset, raster layer, raster band, layer file .lyr)

    The Raster Calculator tool generally follows the standard connectivity behavior of models in ModelBuilder, with some exceptions resulting from the requirements of formulating a valid map algebra expression. These include the following:

    • Variables are connected to the Raster Calculator tool when they are selected from the list of variables. All variables are automatically listed in the Variable list in the tool.
    • When a dataset or variable is used in the expression, a link between the variable and the tool will be created. If you remove the variable from the expression, the associated link between the variable and the tool will also be removed.
    • If you delete the connection to a variable, the variable is not removed from the expression.
    • Do not rename a variable that is connected to the tool, since the variable will not be renamed in the expression. If you do rename a variable, the expression will be invalid.
  • Certain Raster storage environments may apply to this tool when output is in a raster format other than Esri Grid.

    • For the Raster Statistics environments, only the Calculate Statistics check box is supported.
    • For the Compression environments, only the type of Compression is supported. This environment will only apply when the output would be of integer type. Compression is not supported on floating point rasters, so this environment will only apply when the output would be of integer type.
    • The Tile Size environment is only supported for raster output in the following formats: TIFF, file geodatabase, or enterprise geodatabase.
  • If all the inputs are multidimensional raster data with the same number of variables, the tool will perform the operation for all slices with the same dimension value. The output will be a multidimensional raster in CRF format. The variable in the inputs must have at least one common dimension and one common dimensional value for this tool to process; otherwise, an error will occur.

    If all inputs have one variable but different names, uncheck the Match Multidimensional Variable geoprocessing environment (set arcpy.env.matchMultidimensionalVariable = False in Python) before running the tool.

    If one of the inputs is a multidimensional raster and the other input is a constant, the tool will perform the operation for all slices for all variables using the constant value, and the output will be a multidimensional raster.


LabelExplanationData Type
Map Algebra expression

The map algebra expression that will be run.

Create the expression by specifying the inputs, values, operators, and tools to use. You can type in the expression directly or use the controls to create it.

  • The Rasters list identifies the datasets available to use in the map algebra expression.
  • The Tools list contains commonly used tools you can use.
Raster Calculator Expression
Output raster

The output raster resulting from the map algebra expression.

Raster Dataset

RasterCalculator(expression, output_raster)
NameExplanationData Type

In Python, create and run map algebra expressions using the Image Analyst module, which is an extension of the ArcPy Python site package.

See Map algebra to learn how to perform an analysis in Python.

Raster Calculator Expression

See Create output for information about producing output from map algebra expressions in Python.

Raster Dataset

Licensing information

  • Basic: Requires Image Analyst or Spatial Analyst
  • Standard: Requires Image Analyst or Spatial Analyst
  • Advanced: Requires Image Analyst or Spatial Analyst

Related topics