I am trying to do a very simple calculation on a raster.
I have done this kind of work many times, but I can't figure out what has gone wrong this time around.
import arcpy, numpy
from arcpy import env
from arcpy.sa import *
import time
start_time = time.time()
arcpy.CheckOutExtension("Spatial")
env.overwriteOutput = True
env.workspace = "G:/GIS Data/DMSPOLSRC/Radiance_Calibrated"
arcpy.env.scratchWorkspace="G:/GIS Data/scratch"
#1996
inRaster1 = arcpy.Raster("F12_19960316-19970212/F12_19960316-19970212_rad_v4.avg_vis.tif")
outRaster="rescaled/f1296rsc"
tempRaster=0.915*inRaster1
outCon = Con((inRaster1 ==0), 0 , 4.336+tempRaster)
outCon.save(outRaster)
print time.time() - start_time, "seconds, f121996completed"
Python returns the following error message
Traceback (most recent call last):
File "G:\GIS Data\DMSPOLSRC\Radiance_Calibrated\rescaling.py", line 16, in <module>
outCon.save(outRaster)
RuntimeError: ERROR 999998: Unexpected Error.
In other words something is going wrong when it tries to save the raster. I cant figure out for the life of me whats happening.
I should note the following
a) If I comment out the problematic line, it moves on and prints the time taken. In other words, it seems like there i no problem with the raster calculation itself.
b) If I go into ArcMap and use the raster calculator there, there is no problem if I save the outRaster to an existing geodatabase folder. However, it will return the following error when I try to save it to the target folder above:
Messages
Executing: RasterCalculator Con("F12_19960316-19970212_rad_v4.avg_vis.tif"==0,0, 4.336+0.915 * "F12_19960316-19970212_rad_v4.avg_vis.tif") "G:\GIS Data\DMSPOLSRC\Radiance_Calibrated\rescaled\f121996rsc"
Start Time: Fri Jun 22 11:26:13 2018
Con(Raster(r"F12_19960316-19970212_rad_v4.avg_vis.tif")==0,0, 4.336+0.915 * Raster(r"F12_19960316-19970212_rad_v4.avg_vis.tif"))
ERROR 000539: Error running expression: rcexec()
Traceback (most recent call last):
File "<expression>", line 1, in <module>
File "<string>", line 8, in rcexec
RuntimeError: ERROR 999998: Unexpected Error.
Failed to create raster dataset
Failed to execute (RasterCalculator).
Failed at Fri Jun 22 11:26:14 2018 (Elapsed Time: 0.85 seconds)
I am running ArcGis Desktop 10.6 and the python version is 2.7.14 (which comes with ArcGis).
Thanks