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...

Working with operators in Map Algebra

Available with Spatial Analyst license.

  • Operator rules
  • Operator precedence

In Map Algebra, operators apply a mathematical operation on input rasters and numbers.

Operators are generally placed between two inputs (operands) to perform a mathematical operation (for example, outVar = 3 + 7). In Map Algebra, operands can be rasters or numbers. To use an operator with a raster, the raster must be a Raster object.

The table below provides a quick reference indicating how current Map Algebra operators have been implemented in relation to Python operators and previous 9.x Map Algebra operators.

OperationPython operatorMap Algebra operator9.x Map Algebra operator *Spatial Analyst GP tool
Arithmetic

Addition

+

+

+

Plus

Division

/

/

/, div

Divide

Integer Division

//

//

N/A

N/A

Modulo

%

%

Mod

Mod

Multiplication

*

*

*

Times

Power

**

**

N/A

Power

Subtraction

-

-

-

Minus

Unary Minus

-

-

-

Negate

Unary Plus

+

+

N/A

N/A

Boolean

Boolean And

N/A

&

&, and

Boolean And

Boolean Complement

N/A

~

^, not

Boolean Not

Boolean Exclusive Or

N/A

^

!, xor

Boolean XOr

Boolean Or

N/A

|

|, or

Boolean Or

Relational

Equal To

==

==

==, eq

Equal To

Greater Than

>

>

>, gt

Greater Than

Greater Than And Equal To

>=

>=

>=, ge

Greater Than Equal

Less Than

<

<

<, lt

Less Than

Less Than And Equal To

<=

<=

<=, le

Less Than Equal

Not Equal To

!=

!=

^=, <>, ne

Not Equal

Bitwise

Bitwise And

&

N/A

&&

Bitwise And

Bitwise Complement

~

N/A

^^

Bitwise Not

Bitwise Exclusive Or

^

N/A

!!

Bitwise XOr

Bitwise Left Shift

<<

<<

<<

Bitwise Left Shift

Bitwise Or

|

N/A

||

Bitwise Or

Bitwise Right Shift

>>

>>

>>

Bitwise Right Shift

* 9.x Map Algebra operator refers to the operator symbol you would have used in the Single Output Map Algebra tool or the Raster Calculator in the Spatial Analyst toolbar in ArcGIS versions 9.x and prior.

Operator rules

  • When only numbers are used with operators, the result will be a number.
    # outVar will be assigned 10
    outVar = 3 + 7
    
  • When using operators with rasters, the raster must be a Raster object.
    outRas = Raster("inraster1") + Raster("inraster2")
    
  • When a raster operand is used, then the result is a Raster object.
    # In the following statement, 4 is added to each cell value in inraster1
    outRas = Raster("inraster1") + 4  
    outRas2 = Raster("inraster") + math.pi
    

    In the above statement, pi is used from the Python math module. The math module also includes the base of the natural logarithm, math.e, which can also be used in a Map Algebra statement.

  • Some operators can precede a Raster object or a number.
    outRas = -Raster("inraster")
    
  • The Boolean (~, &, ^, |) operators will perform a Boolean operation when one or more input (operand) is a raster. If both inputs (operands) are numbers, then these operators will perform Bitwise operations.

Tip:

Spaces are not necessary between operators but are recommended for readability.

Tools and operators can be nested to create complex statements.

  • Learn more about building complex statements

Operator precedence

The precedence value determines the order in which operators are executed. The operator with the higher precedence will be processed first. If two operators have the same precedence value, then they will be processed in a left to right order in an expression.

You can use parentheses to override the precedence priority, with the operation in the deepest parentheses being processed first no matter what operator is specified.

The following table lists all the Map Algebra operators in order from lowest precedence to highest precedence. Each of the operators that are listed in the same row have the same precedence.

Map Algebra operatorReference

<, <=, >, >=, ==, !=

Less Than, Less Than Equal, Greater Than, Greater Than Equal, Equal To, Not Equal

|

Boolean Or

^

Boolean XOr

&

Boolean And

<<, >>

Bitwise Left Shift, Bitwise Right Shift

+, -

Addition, Subtraction

*, /, //, %

Multiplication, Division, Integer Division, Modulo

+, -, ~

Unary Plus, Negate, Boolean Not

**

Power

Related Topics

  • An overview of the rules for Map Algebra
  • An overview of the Map Algebra Operators
  • 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