ERROR

Error running expression: rcexec()

Last Published: December 9, 2022

Error Message

When running a Python script exported from ModelBuilder that includes a Raster Calculator function, the code fails because it is not able to run the rcexec() expression. The following error message is returned:

"ERROR 000539: Error running expression: rcexec()"

Cause

This error is due to Raster Calculator not being exposed to Python as a tool. Currently, Raster Calculator is only exposed as a geoprocessing tool in ArcGIS or in ModelBuilder. If the user exports a model containing a Raster Calculator expression, it enters arcpy.rcexec() into the script. When the script is run, the 000539 error is encountered.
However, there are a number of different ways to use Raster Calculator functions in Python, as shown in the example below.

This error has also been returned running the Raster Calculator, when the output is specified as an ArcInfo GRID, and a UNC path is specified for the output. The tool executes successfully, without any errors, if the output is a TIFF, for example.

Solution or Workaround

Delete the rcexec() and use the article sample below to build your own math expression.

This example shows how Python can use the Spatial Analyst Math toolset to perform mathematic functions on raster datasets, in a stand-alone script that can be run outside of the arcmap process.

  1. Open a Python IDE.
  2. Create a Python script using the Math toolset function.

    Sample using the Minus function:
# Name: Minus_Ex_02.py
# Description: Subtracts the value of the second input raster from the
#              value of the first input raster on a cell-by-cell basis
# Requirements: Spatial Analyst Extension

# Import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# Set environment settings
env.workspace = "C:/sapyexamples/data"

# Set local variables
inRaster1 = "degs"
inRaster2 = "negs"

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Execute Minus to subtract inRaster2 from inRaster1
outMinus = Minus(inRaster1, inRaster2)

# Save the output 
outMinus.save("C:/sapyexamples/output/outminus.tif")
  1. Run the Python script.

Article ID:000011928

Software:
  • ArcMap 10 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options