0

I have about 20 raster files in a directory. I want to sum all the rasters into one new raster. The code I wrote was:

currentDir=os.getcwd()
tempDir=currentDir+'\\tmp'

arcpy.CheckOutExtension("spatial")
arcpy.env.overwriteOutput = True

arcpy.env.workspace=currentDir+'\\tmp'
sumRas=arcpy.ListRasters("rr*", "TIF")

outCellStatistics = CellStatistics(sumRas, "SUM", "DATA")

When I run it I get this message:

Traceback (most recent call last): 

File "D:\SAPROGtrab\CPIR.py", line 50, in outCellStatistics = CellStatistics(sumRas, "SUM", "DATA") 

File "D:\programas\ArcGIS\Desktop10.6\ArcPy\arcpy\sa\Functions.py", line 3173, in CellStatistics ignore_nodata) 

File "D:\programas\ArcGIS\Desktop10.6\ArcPy\arcpy\sa\Utils.py", line 53, in swapper result = wrapper(*args, **kwargs) 

File "D:\programas\ArcGIS\Desktop10.6\ArcPy\arcpy\sa\Functions.py", line 3169, in Wrapper [function] + Utils.flattenLists(in_rasters_or_constants)) 

RuntimeError: ERROR 999998: Unexpected Error.

If I run it with only 3 raster files it work ok.

Any idea about this error?

0
2

I have found the solution. Added the following line of code.

arcpy.env.extent = 'MAXOF'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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