[GIS] problem with “Con” conditional expression

arcgis-10.0arcpy

I created a python script where I use Con (Spatial Analyst). Till now I passed the where clause value as value>1000 and it worked fine for me. But recently I found some raster on which Con statement does not work and says that the expression is not valid or something like that. Now I put space before and after > sign and the expression is now value > 1000. The weird thing is the script works fine now.

Con does not work when con expression is value>1000, for raster files that are big in size, but works fine when con expression is value > 1000, for my case, it was 50MB. Only putting two spaces solves the problem

Question:
I go through Con (Spatial Analyst) documentation. I do not find anything that can explain why is this happening. Can anybody explain Why is this weird thing happening?

Best Answer

Many tools will fail if the there are no spaces around the operands. It is just good practice. Here are several other links dealing with Con http://forums.arcgis.com/threads/13219-Con-statement-error-in-raster-calculator?p=40419&posted=1#post40419 and
http://forums.arcgis.com/threads/21664-con-function-use-in-the-raster-calculator?p=70771&posted=1#post70771

Try to select entry grids and operands rather than typing them in if you are using the raster calculator. Also, keep a text file of statements that you might use regularly so that the correct syntax is on hand. Good luck.

Related Question