Select to view content in your preferred language

syntax error in con statement

3111
6
Jump to solution
01-04-2011 03:17 PM
AshleyJohnson
New Contributor
I am using a land value grid and am trying to use a con statement to set certain land values equal to 1 and all else equal to 0. This is my syntax: con (Raster1 >=135000 & Raster1 <=175000, 1, 0)

I have tried so many different ways to write this, double (, spaces, etc. And I continue to get the error message 000539; the truth value of a raster is ambiguous. What am I doing wrong?

Any help is appreciated.
I am running ArcGIS 10, ArcView with Spatial Analyst
0 Kudos
1 Solution

Accepted Solutions
DanPatterson_Retired
MVP Emeritus
I suggest that you type as little as possible and use the selection options within the raster calculator as much as possible
con (Raster1 >=135000 & Raster1 <=175000, 1, 0)

might be
con( ("Raster1" >= 135000) & ("Raster1" <= 175000), 1, 0)
if memory serves, grid names are enclosed in " " in version 10 and [ ] in 9.x, also put ( ) around statements that use boolean operations. and check the forum, this has been documented previously
http://forums.arcgis.com/threads/13219-Con-statement-error-in-raster-calculator?p=40419&posted=1#pos...

View solution in original post

0 Kudos
6 Replies
DanPatterson_Retired
MVP Emeritus
I suggest that you type as little as possible and use the selection options within the raster calculator as much as possible
con (Raster1 >=135000 & Raster1 <=175000, 1, 0)

might be
con( ("Raster1" >= 135000) & ("Raster1" <= 175000), 1, 0)
if memory serves, grid names are enclosed in " " in version 10 and [ ] in 9.x, also put ( ) around statements that use boolean operations. and check the forum, this has been documented previously
http://forums.arcgis.com/threads/13219-Con-statement-error-in-raster-calculator?p=40419&posted=1#pos...
0 Kudos
AshleyJohnson
New Contributor
Thank you!
0 Kudos
AshleyJohnson
New Contributor
Not to be greedy, but how would I nest a set null statement in there? So instead of setting the false values to 0 I would set them to null?
0 Kudos
curtvprice
MVP Esteemed Contributor

> how would I nest a set null statement in there? So instead of setting the false values to 0 I would set them to null?

Or if you like the simplicity of Con, just leave off the false_expression:

Con(("Raster1" >= 135000) & ("Raster1" <= 175000), 1)
DanPatterson_Retired
MVP Emeritus
AshleyJohnson
New Contributor
Thanks so much, good stuff. I appreciate it.
0 Kudos