1

How can I write the following conditional statement with CON?

If ((VALUE = 20 OR IF VALUE=24) then assign value 0, else 1)

Con(("Raster1", 0, 1, "VALUE =20")|("Raster1", 0, 1, "VALUE =24"),0,1)

I just can´t get this to work

4
  • It seems this works although the operator "OR" doesn´t exist in the RasterCalculator Con("Raster1", 0, 1, "VALUE =20 OR VALUE =24") Commented Jul 30, 2015 at 15:00
  • See if in (20,24) will work. It does on tables
    – FelixIP
    Commented Jul 30, 2015 at 17:32
  • Why use con at all? !(("Raster1"==20) | ("Raster1"==24)) should do it. You could even use alternatives like abs("Raster1"-22)!=2. Although that's a poor choice--it's harder to understand--it leads to a superior solution for floating point rasters, whose values might not exactly equal 20 or 24. You can now easily add a tolerance, such as abs(abs("Raster1"-22)-2)>0.00001. That helps you avoid a nasty pitfall. (Note that the details of the syntax depend on what version of ArcGIS you are using.)
    – whuber
    Commented Jul 30, 2015 at 21:30
  • Please help. Trying to create multiple rules using Con tool in ArcMap. Thanks! Con("OM_petit.tif" > 2.5, ("soil_pH_petit.tif" >= 5.5, ("clay_petiit.tif" >24.3) & ("awc_petit.tif" <= 0.09,1,Con(("OM_petit.tif" > 2 and <= 2.5 , ("soil_pH_petit.tif" >= 5.3 and < 5.5, ("clay_petiit.tif" > 18.5 and <= 24.3) & ("awc_petit.tif" > 0.09 and <= 0.16,2,Con(("OM_petit.tif" >= 0.75 and <1.5, ("soil_pH_petit.tif" >= 4.6 and < 5.0, ("clay_petiit.tif" >= 12.5 and <= 15.5) & ("awc_petit.tif" == 0.23,3,Con(("OM_petit.tif" < 0.75, ("soil_pH_petit.tif" < 4.6, ("clay_petiit.tif" < 12.5) & ("awc_petit.tif" > 0.23,4
    – Jane
    Commented Feb 27, 2019 at 15:01

1 Answer 1

6

Read about Raster Calculator operators. The bar "|" symbol is the OR operator.

The correct syntax would be:

Con(("Raster1" == 20) | ("Raster1" == 24), 0, 1)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.