AnsweredAssumed Answered

Fill causes syntax error in parsing grid expression when run in background

Question asked by p261080_RUG on Mar 16, 2017
Latest reply on Apr 7, 2017 by xander_bakker

I'm trying to use arcpy.sa.Fill in a python toolbox command, however it always fails with the following error:

Executing: FillFailTest C:\proef\mv_gron
Start Time: Fri Apr 07 10:19:57 2017
Running script FillFailTest...

Workspace was C:\Users\jelmer\Documents\ArcGIS\Default.gdb
Workspace is C:\WorkSpace

Traceback (most recent call last):
File "<string>", line 34, in execute
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\sa\Functions.py", line 2089, in Fill
z_limit)
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\sa\Utils.py", line 53, in swapper
result = wrapper(*args, **kwargs)
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\sa\Functions.py", line 2085, in Wrapper
z_limit)
File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\geoprocessing\_base.py", line 513, in _callback
return val(*gp_fixargs(args, True))
ExecuteError: ERROR 010328: Syntax error at or near symbol ).
ERROR 010267: Syntax error in parsing grid expression.
Failed to execute (Fill).

Failed to execute (FillFailTest).
Failed at Fri Apr 07 10:19:59 2017 (Elapsed Time: 1,45 seconds)

The odd thing is, the fill command works fine if I run it from the embedded arcpy console:

from arcpy.sa import Raster
from arcpy.sa import Fill
x = Raster(r'C:\test\mv_gron')
y = Fill(x, 40)

(Updated) To test Shaun's solution, I've also added these lines:

arcpy.env.workspace = r"C:\WorkSpace"
arcpy.env.scratchWorkspace = r"C:\WorkSpace"

It also works fine when I set the canRunInBackground property of the tool to False. Is there a way to run the too with the Fill call in the background?

 

I've attached a small toolbox example that fails for me.

 

(Update 2) I'm starting to doubt whether it has something to do with canRunInBackground or not. Currently, the Fill tool and arcpy.sa.Fill only work when used directly in ArcMap. If I call arcpy.sa.Fill in a python toolbox from inside ArcMap, or from IDLE, I encounter the syntax error. All paths are already short and simple, except for the install location of ArcMap (which is in the default C:\Program Files (x86)\Ar..etc).

Attachments

Outcomes