Introduction to map algebra

Available with Spatial Analyst license.

Available with Image Analyst license.

Map algebra is a simple and powerful algebra with which you can run all Spatial Analyst tools, operators, and functions to perform geographic analysis. Map algebra is available through the Spatial Analyst module; an extension of the ArcPy Python site package. As map algebra has been integrated in Python, all the functionality of Python and ArcPy and its extensions (modules, classes, functions, and properties) is available to you.

License:

You can also use map algebra in Python if you have an Image Analyst extension license available. Not all of the tools available in Spatial Analyst can be used in Image Analyst, however. You can see the categories of available tools in the Image Analyst toolbox overview. The rest of the discussion in the map algebra section here will mention Spatial Analyst specifically, but where appropriate it will apply equally well when using the functionality with an Image Analyst license.

Spatial Analyst tools are accessed through an algebraic format. That is, an object whose name is identified to the left of an equal sign is created based on a tool or operator stated to the right of the equal sign.

from arcpy.sa import *
outRas = Slope("indem")

The above statement calculates the slope for each cell in the indem dataset and creates a Raster object called outRas to store the results. Specific information on importing the Spatial Analyst module to use map algebra can be found at Import the Spatial Analyst module.

To use the tools with an Image Analyst extension license, use the following syntax to import the ia module:

from arcpy.ia import *
outRas = Slope("indem")

Map algebra within Python is composed of tools, operators, functions, and classes. For more information on the syntax rules of map algebra, refer to the following resources:

Related topics