AnsweredAssumed Answered

arcpy.sa save random ERROR 999998: Unexpected Error

Question asked by mcdo0007 on Jun 16, 2018
Latest reply on Jun 18, 2018 by mcdo0007

I am working on a pilot for a system that will eventually loop over a number of raster files to produce a single output one.  If I have two input rasters, the routine works reliably.  If I have more than three, it always fails.  If I try three after a failure, it fails, but it can be made to work by first resorting to just two inputs and then adding the third.  This is my (anonymised) code:

import arcpy
from arcpy.sa import *

arcpy.CheckOutExtension("Spatial")
arcpy.env.extent = "MAXOF"
arcpy.env.overwriteOutput = True
arcpy.env.qualifiedFieldNames = False
arcpy.env.workspace = "C:\aaaa"

inRasDir = bbb\\"
outRasDir = ccc\\"

terms = {}
terms = {
     'first'  : ['0.025', '*', '+', ],
     'second' : ['0.025', '*', '+', ],
     'third'  : ['0.025', '*', '+', ],
     'fourth'  : ['0.15',  '*', '-']
    }

def coeff(lyr):
    if terms[lyr][2] == '+':
        c = float(terms[lyr][0])
    else:
        c = -float(terms[lyr][0])
    return c;

outRas = ((
             (coeff('first')  * Raster(inRasDir + "first"))
           + (coeff('second') * Raster(inRasDir + "second"))
           + (coeff('third')  * Raster(inRasDir + "third"))
#           + (coeff('fourth')  * Raster(inRasDir + "fourth"))
            )
#           * 'fifth'
           )

outRas.save(outRasDir + "finalRas")

The error on the last line is:

    outRas.save(outRasDir + "finalRas")
RuntimeError: ERROR 999998: Unexpected Error.

I also tried using CellStatistics but that also failed on the save statement.

Any comments would be gratefully received.

Regards,

Ian

Outcomes