Arcpy script results in RuntimeError: ERROR 999998: Unexpected Error

04-14-2020 04:42 AM
New Contributor

I made this pretty simple tool with the code below and all through last night it ran error free on every run. Now since this morning I am getting a RuntimeError: 999998: Unexpected Error. The error occurs on line 15:'D:\Documents\LocalReliefModel\TestRaster\difmodel.tif')

I have no idea why it isn't working all of the sudden. I can see it writing the raster file in the given location, but it gets deleted immediately and than the RuntimeError happens. I can't really find any solution and have tried different paths, names, setting it as a variable, etc.

Does anyone know what to do?

import arcpy
from import *

arcpy.env.overwriteOutput = True
arcpy.env.workspace = r'D:\Documents\LocalReliefModel'

DEM_org = r'D:\Documents\LocalReliefModel\TestRaster\GH_Toterfout.tif'

# Low pass filter -> Smoothed DEM (focal statistics)
outFocalStat =, NbrRectangle(50, 50, "CELL"), 'MEAN')'D:\Documents\LocalReliefModel\TestRaster\LPF.tif')

# Subtract smoothed DEM from the original DEM -> Difference model (Minus function)
outMinus =, DEM_org)'D:\Documents\LocalReliefModel\TestRaster\difmodel.tif')

# Calculate the zero meters contours for the Difference model ->
# set of the break lines between the positive and negative features (convex and concave features; Contour function)
outCont_save = r'D:\Documents\LocalReliefModel\TestRaster\ZeroCont.tif'
outCont =, outCont_save, 100)

# Extract the real elevation of the cells from the original DEM, which intersects with the break lines ->
# simplified elevation raster (Extract by Mask function)
outMask =, outCont)'D:\Documents\LocalReliefModel\TestRaster\ElExtract.tif')

# Convert the simplified elevation raster to the point features (only nonzero cells) ->
# elevation points (Raster to Point function)
outRastToPoint_save = r'D:\Documents\LocalReliefModel\TestRaster\RastToPoint'
outRastToPoint = arcpy.RasterToPoint_conversion(outMask, outRastToPoint_save)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Tags (2)
0 Kudos
5 Replies
MVP Esteemed Contributor

you said you tried different paths, but did you attempt changing the names?

New Contributor

The issue is resolved now. The problem was with writing in-memory and not on drive. Thanks!

0 Kudos
MVP Regular Contributor

Maybe because your outFocalStat is a raster object rather than a path.

also you a using explicitly so theres no need for from import *

one last guess might be not having


New Contributor

Thanks for your reply! The problem has been solved by moving all the .save functions to the end of the script. 

I still need import * for NbrRectangle for some reason. 

0 Kudos
Esri Regular Contributor

because it is in the Spatial Analyst module