[GIS] Map Algebra expression in a model fails on open workspace

arcgis-desktoperror-000539map-algebramodelbuilder

I have model which runs 2 processes that create rasters and a third process that (attempts to) add the two of them using Map Algebra. The expression is very simple, just "%Raster_A%" + "%Raster_B%".

This third process aborts with ERROR 000539: Error running expression: rcexec() <type 'exceptions.RuntimeError'>: ERROR 010167: Could not open workspace .

The help file for Error 000539 : Error message from Python does not appear relevant, this isn't a problem with python syntax or type use. There is no help page for #010167, but the "not open workspace" is self explanatory.

I haven't found any info on rcexec() but name and context suggest it's a method for shelling out to an external python process and getting something back. It's reasonable to assume the external process doesn't know it's being executed from a model and that the workspace lock it's encountering is from the parent, and that this is okay. Or, maybe rcexec is not encountering a lock and what's really having trouble with is finding the workspace. I have no way of knowing (I don't think).

The model has an Output Workspace input parameter, which the two antecedent processes use just fine. I tried connecting the Output Workspace input parameter to the map algebra expression as Enviroment > Workspace > Current Workspace to no effect.

Any ideas how to track the source of this error down and fix it?


update: Aha! The environment is not clean. I edited the model and deleted the Current and Scratch workspace settings, and they reverted to the default C:\Users\matt\ArcGIS\default.gdb. At that point the error changed from can't open to invalid workspace:

ERROR 000539: Error running expression: rcexec() <type 'exceptions.RuntimeError'>:
ERROR 000875: Output raster: T:\env298.gdb\A_plus_B's workspace is an invalid output workspace.

The curious thing is that the workspace specified in the error was the model's workspace at one time. So rcexec() is not respecting the value set in the model's environment properties, nor the process's workspace environment property.

Now I just need to figure out how to really reset the environment to defaults.

Best Answer

sigh. PEBKAC. Tunnel vision. I was so busy looking at environment settings and model parameters that I didn't inspect closely the actual problem process's in-tool parameters --- those that you see when opening the tool via the normal interactive dialog as opposed to looking at properties and connectors.

Somewhere along the line the Map Algebra output raster field was set to a hard coded path instead of the desired %Output Workspace%\out_raster_name. Change that and it's all good.