Error 999999 in arcpy after ArcGIS Pro Crashes

12-10-2019 10:48 AM
New Contributor

I'm having a bit of a strange issue; the code below worked just fine yesterday but when I re-ran it and added a backlink raster to the output of the CostDistance tool on line 71 it caused ArcGIS Pro to crash (there was no open instance of ArcGIS Pro at the time, I can only assume it was opened for background processing or something). I don't really need the backlink so no problem I thought, so I just restarted my IDE (Spyder) and when I tried to run it again it gave me an

ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support ( to Report a Bug, and refer to the error help for potential solutions or workarounds.
Failed to create raster dataset
Failed to execute (Fill).

on line 28

elev_filled = Fill(inSurfaceRaster)

There have been a few previous cases where anaconda or python froze during some operation and it resulted an Error 999999 when I restarted, but it was always easily fixed by deleting the contents of C:\users\{myname}\AppData\local\Temp; this time however the problem has persisted. I've tried running the code on the python window of ArcGIS Pro, in an ArcMap 10.6 arcpy environment, and in Jupyter Notebooks and each one gives the Error 999999; however, it works fine when I use the Fill tool in ArcGIS Pro Desktop.

Anyone have any idea what's up? I'm guessing the unexpected exit of ArcGIS Pro left some debris on my system that would normally have been cleaned up in a normal exit but outside of the temp folder I'm not sure where to look. I've also tried rebooting the system (after deleting the temp folders) and running both spyder and ArcGIS Pro as an administrator.

Update: I tested it in the python window in ArcMap 10.6 on my computer and still got the Error 999999; I tried it out in the python window of ArcMap 10.6 on a different computer and it *did* work.

It strikes me that I don't know how to add line numbers to this code block and the spaces between lines have disappeared, so hopefully it's not too much trouble for you all.


# -*- coding: utf-8 -*-
#Import packages, check out extensions
import arcpy
from arcpy import env
from import *
import geomorph_routines_module

# Set environment settings
env.workspace = r'D:\hydro_RI\data'
env.overwriteOutput = 1

# Set local variables
#inSurfaceRaster = env.workspace + '\\' + 'grdn42w072_13'
inSurfaceRaster = env.workspace + '\\' + 'rhodeIslandDEM.tif'
#outDropRaster = "D:\\hydro_RI\\data\\dropraster"
outBacklinkRaster = "D:\\hydro_RI\\data\\backlink"
#sample_points = 
stream_threshold = 50000
#declares units of the map; need to add some code to figure this out
inZUnits = 'Meters'

#Set raster calculation details
env.extent = inSurfaceRaster
env.cellSize = 10

# Fill sinks in the raster 
elev_filled = Fill(inSurfaceRaster)
#elev_filled = Fill(r"D:\hydro_RI\data\rhodeIslandDEM.tif")

#Calculate flow direction
outFlowDirection = FlowDirection(elev_filled, "FORCE", outDropRaster, 'D8')

#Calculate flow accumulation
flow_accum = FlowAccumulation(outFlowDirection)

#Calculate watershed areas feeding into locations of sample points;
streamThreshold = SetNull(flow_accum <= stream_threshold,flow_accum)
strahler_threshold = StreamOrder(streamThreshold, outFlowDirection, 'STRAHLER')
strahler_link = StreamLink(strahler_threshold, outFlowDirection)

#Clip relevent watersheds to reduce processing time of indices
#clip_feature = arcpy.RasterToPolygon_conversion (polluted, env.workspace + '\\' + 'clipFeat.shp' , "NO_SIMPLIFY")
#wshd_clip = arcpy.Clip_management(elev_filled, '#', env.workspace + '\\' + 'wshd_clip.tif',clip_feature, "0", "ClippingGeometry")

#Basis for CTI
clippedFootprint = geomorph_routines_module.checkExt(elev_filled)
zFactor = geomorph_routines_module.getZFactor(clippedFootprint,inZUnits)
slope = Slope(clippedFootprint,"DEGREE",zFactor)
radSlope = Divide(Times(slope,1.570796),90)
tan_slp = Con(radSlope > 0, Tan(radSlope), 0.001)

# Getting info on raster
dscRaster = arcpy.Describe(clippedFootprint)
inSpRef = dscRaster.spatialReference
spRefType = inSpRef.type
cellSize = dscRaster.meanCellHeight
if spRefType == "Geographic":
 cellSize = cellSize/zFactor

#Calculate flow direction and flow accumulation of filled rastter
clippedFlowDirection = FlowDirection(clippedFootprint)
clippedFlowAcc = FlowAccumulation(clippedFlowDirection)

corr_flowAcc = Times(Plus(clippedFlowAcc,1),cellSize)
twiRaster = Ln(Divide(corr_flowAcc,tan_slp)) + '\\' + 'twiRI')
#Cartographic depth to water index (DTW)
dtwRaster = CostDistance (strahler_threshold, tan_slp, '', '') + '\\' + 'dtwRI')‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
Tags (2)
0 Kudos
2 Replies
MVP Esteemed Contributor

Give the Syntax Highlighter a try to format your code:

That should just about do it....
0 Kudos
New Contributor

Done, thanks!

0 Kudos