Con statement error in raster calculator

3454
3
Jump to solution
09-17-2010 07:14 PM
RichardRupp
New Contributor II
I'm trying to pull out the cells from 2 8-bit integer rasters (same area, different years) that have the same value. The raster calculator statement:

Con("raster1" == 61 & "raster2" == 61, 1, 0)

The error: rcexec()<type 'exceptions.ValueError'>: The truth value of a raster is ambiguous.

These are FGDB rasters, but I get the same results with grids. I've also tried this on a couple of different computers, and I've created a couple of similar random rasters with the same results. If I break the statement down into simple one (ie Con("raster1" == 61, 1, 0)) it will run.

One possibility is that the raster properties  report both rasters as having a continous data type rather than discrete. I'm not sure how to change that.

I know I can do some reclass work arounds, but I'm at the beginning of a modelling project, and I am hoping to build some more complex Con statements. Any advice is welcome.

I'm working with ArcGIS 10 Arcinfo on 64-bit Windows 7.
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus
the expression parser seems to require ( ) to separate the different conditions before and after &
ie
Con(("polynom2" == 5)  & ("logistic" == 5), 1, 0)

View solution in original post

0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus
the expression parser seems to require ( ) to separate the different conditions before and after &
ie
Con(("polynom2" == 5)  & ("logistic" == 5), 1, 0)
0 Kudos
RichardRupp
New Contributor II
Thanks, Dan! That was one combination of parentheses that I had overlooked. That gave me the results I expected.

Although it is entirely possible I missed it, I don't think this syntax shows up in the ArcGIS documention.
0 Kudos
DanPatterson_Retired
MVP Emeritus
No unfortunately it doesn't...you should forward this thread as an "issue" to tech support.  There is a tendancy to show simple examples and not complex ones.  I don't know if this would classify as a bug, but one would expect & (or any other boolean) to parse the left and the right correctly without the need for brackets.  Otherwise indicate said information (via an example perhaps) in the online help files.  I would also suggest that everyone use the online help rather than the arcmap help since it is updated and the built-in help is static
for version 10
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html?TopicName=welcome
for 9.3
http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=welcome
for previous versions substitute your version number in the appropriate spot.
0 Kudos