Hi Everyone,
I'm using the expression below to try convert all the values that are negative or equal to zero to NoData
SetNull("cov_fdg_ct" <= 0,"cov_fdg_ct")
But it failed to execute with the error message below:
Executing: RasterCalculator SetNull("cov_fdg_ct" <= 0,"cov_fdg_ct") "E:\GIS Data\Thesis modeling\FloodDepthGrids\cov_fdg_c" Start Time: Fri Jun 12 17:49:33 2015 SetNull("cov_fdg_ct" <= 0,"cov_fdg_ct") ERROR 000539: Error running expression: rcexec() Traceback (most recent call last): File "<expression>", line 1, in <module> File "<string>", line 5, in rcexec File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\sa\Functions.py", line 320, in SetNull where_clause) File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\sa\Utils.py", line 47, in swapper result = wrapper(*args, **kwargs) File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\sa\Functions.py", line 309, in Wrapper ["SetNull", in_conditional_raster, in_false_raster_or_constant]) RuntimeError: ERROR 000732: Input Raster: Dataset cov_fdg_ct does not exist or is not supported Failed to execute (RasterCalculator). Failed at Fri Jun 12 17:49:34 2015 (Elapsed Time: 0.16 seconds)
I've been reading many posts from those who also got the ERROR 000539 and most of them seem to be due to a syntax error. However, I can't seem to figure out what syntax error is in my simple expression. It would be much appreciated if you can provide some advice!
Thank you!
Solved! Go to Solution.
SetNull("x","x","VALUE>5")
I would highly recommend getting students away from the SQL parameter and use this instead in Raster Calculator
SetNull("x" > 5, "x")
or in Python
gt5ras = SetNull(Raster("x") > 5, "x")
or in Python (better)
testras = Raster("x") gt5ras = SetNull(testras > 5, testras)
Yes...it is the latter two that I lean towards...specifically, I like them to do it manually once, then emulate the return syntax from the Results window. They can then copy and paste and retain the syntax, in a text file, for future work. It save them having to look it up or whipping quotes around things randomly in the hopes that errors go away
Thank you so much for all your advice and responses! Sorry for the delayed reply - I haven't had access to this GIS machine again until today.
To my surprise, I used the same syntax as I did last week and it got executed successfully as below. Any suggestions to what may have changed?
Darren and Dan - Last week before I posted this message, I have also tried the syntax you have suggested (i.e. including the where clause) but I got the same error. However, when I tried again today, it worked also as shown below.
What I have found interesting was that when I took out the space between the = and 0, it no longer works
You should include spaces between fields, variable names, operators and values as a matter of course to remove/reduce the change that they may become concatenated.
On another note, you are tempting fate by working with rasters data particularly Esri grids, in a folder path that contains spaces...you may and continue to be 'luck' but when you aren't ... remember these words
Good luck
Thank you Dan! I'll change my directories to have no space to be safe - can't rely on luck!