ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcGIS Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Overview of the rules for Map Algebra

Available with Spatial Analyst license.

  • The Map Algebra components

Like all languages, whether for speech, computer programming, or other means of communication, Map Algebra has specific rules for combining the language components.

The general structure of a Map Algebra statement is an assignment operator (=), which is used to separate the action to its right from the name of the output (a raster object) to its left. A statement takes on the following algebraic form:

Output_Name = Action

The Map Algebra components

Map Algebra expressions are made up of five components.

Tools and functions

Geoprocessing tools and functions (such as Sin, Slope, and Reclassify) are used in Map Algebra expressions.

For example, to calculate the aspect for each cell in a raster, use the Aspect tool:

outRas = Aspect("C:/Datat/inraster")
  • Learn more about executing tools in Map Algebra

Operators

Operators are symbols used to represent mathematical operations to be applied to the input.

For example, the following is used to add two rasters together:

outRas = Raster("inraster1") + Raster("inraster2")

Many operators are used in both Map Algebra and Python; the operators are overloaded. When applying operators to raster datasets, you must cast the dataset using Raster, as shown above. Casting the raster indicates that the operation should be applied to rasters, thus calling the Spatial Analyst implementation of the operator, which results in an output raster object.

If only numbers are entered into a statement, the Python implementation of the operator will be used, producing an output number. For example:

# In the following statement outVar will be set to 15
outVar = 6 + 9
  • Learn more about working with operators

Input

The input elements, such as rasters, features, numbers, constants, objects, and variables, are the components on which the statement is applied.

For example, use the following to apply the sine calculation to each cell in an input raster:

outRas = Sin("inraster")
  • Learn different ways to specify input data

Tool parameters

Tool parameters define how the tool is to be executed. Each tool has its own unique set of parameters. Some parameters are required; they must have values for the tool to execute. Other parameters are optional, meaning you can leave them blank and/or accept their default values.

For example, to calculate the slope of a raster, set the optional output measurement parameter with the PERCENT_RISE keyword:

outRas = Slope("inraster", "PERCENT_RISE")
  • Learn more about specifying tool parameters in Map Algebra

Output data

The output from a Map Algebra expression will be a Raster object referencing temporary raster data.

For example, the following will store the results from the slope calculations as a Raster object named outRas:

outRas = Slope("inraster")
Note:

As with all geoprocessing tools, Map Algebra statements honor the environment settings and the selected set.

Consistent with Python, commas are required between each input parameter; spaces are optional between arguments but are recommended for readability. Comments can be added to your script by starting a line with the pound sign (#):

# The following statement takes the slope of the input elevation
outRas = Slope("elevation")
  • Learn more about creating output

Related Topics

  • What is Map Algebra?
  • Building complex statements
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal