I'm getting the following error without any documentation whenever I attempt to save a raster dataset after having used any algebraic functions (with any other raster or constant):

Traceback (most recent call last):

File "C:\Python27\ArcGIS10.6\Lib\site-packages\pythonwin\pywin\framework\interact.py", line 575, in OnEditExecClipboard exec o in main.dict File "", line 95, in RuntimeError: ERROR 999998: Unexpected Error.

I've tried to minimize memory utilization by going as far as breaking it down into as many small pieces as I can and deleting the variables after using them. I've also tried using Plus(,) instead of +, Times(,) instead of *, taking things outside of loops and doing them individually, and nothing. I can save the output of any other function as long as there was never any algebra involved in the leadup Any suggestions? Here's one version of my code:

import arcpy as arc
arcpy.env.overwriteOutput = True
arcpy.env.workspace = "C:\Users\hp\Documents\Work\EE_Model"
arc.env.outputCoordinateSystem = arcpy.SpatialReference("WGS 1984 UTM Zone 014N")
arcpy.env.cellSize = "MINOF"

# Set up Soil Raster

# Create Soil sub-Rasters

arc.conversion.PolygonToRaster("Soil_Cut.shp","N_G1","N_G1.tif",cellsize = 200.0)
arc.conversion.PolygonToRaster("Soil_Cut.shp","N_G2","N_G2.tif",cellsize = 200.0)
arc.conversion.PolygonToRaster("Soil_Cut.shp","N_G3","N_G3.tif",cellsize = 200.0)

print "Soils Converted"

N_G1 = arc.sa.Int("N_G1.tif")
N_G1 = "N_G1.tif"

N_G2 = arc.sa.Int("N_G2.tif")
N_G2 = "N_G2.tif"

N_G3 = arc.sa.Int("N_G3.tif")
N_G3 = "N_G3.tif"

print "Soils Interpolated"


EDIT: I should also note that trying to call a method like .minimum or .maximum results in this error:

Traceback (most recent call last):

File "C:\Python27\ArcGIS10.6\Lib\site-packages\pythonwin\pywin\framework\interact.py", line 575, in OnEditExecClipboard exec o in main.dict File "", line 22, in RuntimeError: ERROR 999998: Unexpected Error.

  • 2
    arcpy.env.workspace = r"C:\Users\hp\Documents\Work\EE_Model"
    – BBG_GIS
    Dec 3, 2017 at 0:53
  • Nope, that doesn't change anything... I should also add that trying to call methods like .minimum and .maximum results in another error. Dec 3, 2017 at 1:13
  • Save to grid format?
    – FelixIP
    Dec 3, 2017 at 1:45
  • Also arcpy.Raster( ng1) might help.
    – FelixIP
    Dec 3, 2017 at 1:47
  • Esri GRID didn't work either. What do you mean by arcpy.Raster might help? if you meant putting it around the times output before saving that didn't do anything. Same error. Dec 3, 2017 at 2:07

1 Answer 1


This is a known bug, and the ArcGIS 10.5.1 (Desktop, Engine, Server) Spatial Analyst Zonal Statistics Tool Patch is available to resolve it:

Esri recommends installing this patch to prevent execution error 999998 in deeply nested map algebra expression with large data or incorrect output with 8 bit input raster from Zonal Statistics.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.