# How to use OR in a CON statement, in the ArcGIS Raster Calculator?

I'm trying to compare two rasters, and create an output based on a formula like:

``````if raster1 > 10 or raster2 < 20 then raster3 = 30
``````

How can I specify the OR in the raster calculator's CON statement?

The pages Building expressions in Raster Calculator and Conditional evaluation with CON don't help, and "or" seems to be keyword that Google ignores....

• please statement with me erosion map with mpeciac method thanks May 30, 2017 at 13:03

It is important to know the precedence level of the operators. For example, Boolean (~, &, ^,|) operators have a higher precedence level than Relational (<, <=, >, >=, ==, !=) operators, which has an impact on how you construct your expressions. For more information on operator precedence, see the second table on this page

I copied the above-mentioned table at the end of my post, it goes from lowest to highest precedence(note that it is not the same precedence in C++). Operators with the highest precedence are grouped together first, this is why you need parentheses if you want to force evaluating ">" before "|".

``````Con(("Raster1" > (10 | "Raster2") < 20),30)
``````

<, <=, >, >=, ==, != (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)

*, /, //, % (Multiplication, Division, Integer Division, Modulo)

+, -, ~ (Unary Plus, Negate, Boolean Not)

** (Power)

• Thanks for the clarification on why the parentheses are required - that makes a lot of sense now Sep 25, 2014 at 9:15

I've just spent ages on this, so to spare everyone else the trouble here's the cheat sheet:

It appears you need to surround each individual comparison in brackets, and use the `|` symbol as the "or":

`Con(("Raster1" > 10) | ("Raster2" < 20),30)`

(Please edit this answer, and post a link to the documentation which mentions this, if it exists)

• resources.arcgis.com/en/help/main/10.1/index.html#//… it's in the table. The brackets around the statements aren't just nice they're absolutely essential - did my head in on that for a few minutes! Sep 25, 2014 at 2:21
• @MichaelMiles-Stimson yeah it's weird since it works without the brackets if you use a simple expression. Googling "boolean or" finds that page you linked, too. Sep 25, 2014 at 2:23