AnsweredAssumed Answered

Error when saving a raster

Question asked by dschatt on May 21, 2018
Latest reply on May 21, 2018 by dschatt

hi, I'm running a loop in 2.7 that does an operation on a series of TIF rasters and saves the resulting TIF rasters respectively.  I keep getting an "Unexpected Error" on the line that exports to a saved raster (bottom line in the code below):


Traceback (most recent call last):
File "C:\Python27\ArcGIS10.5\Lib\site-packages\pythonwin\pywin\framework\", line 326, in RunScript
exec codeObject in __main__.__dict__
File "C:\stuff\SCHISM_SLR_stuff\", line 15, in <module> + labelString + "_Depth_0050_Final.tif")
RuntimeError: ERROR 999998: Unexpected Error.


But it happens sporadically and unpredictably.  Typically it will process several rasters and save the resulting ones, then might stop on this error when saving a particular raster result.  Then I'll delete everything and start it all over again and it will save that raster fine this time, but then I'll get the error on a later raster.  Code below, appreciate any help, thanks!


import arcpy
from import *

arcpy.env.compression = "LZW"

print "Calculating depth..."
arcpy.env.workspace = r"C:\stuff\SCHISM_SLR_stuff\Con_Rasters\Addition_2\Con_0050"
outFolder = "C:\\stuff\\SCHISM_SLR_stuff\\Depth_Rasters\\Addition_2\\Depth_0050\\"
minusRasters = arcpy.ListRasters("*","TIF")
for eachRaster in minusRasters:
    labelString = eachRaster[:19]
    finalDepthRaster = 0.50 - Raster(eachRaster)
    print outFolder + labelString + "_Depth_0050_Final.tif" + labelString + "_Depth_0050_Final.tif")