import arcpy, os from arcpy.sa import * arcpy.env.workspace = r"[abspath]" arcpy.env.scratchWorkspace = r"[abspath]\rescale.gdb" aprx = arcpy.mp.ArcGISProject(r"[abspath]\filename.aprx") # Select correct interpolated rasters for lyr in aprx.listMaps()[0].listLayers(): if lyr.isRasterLayer: if 'Temp' in lyr.name: if 'Int_Raster' in lyr.name: # Set local variables raster = Raster(lyr.dataSource) thresholds = [14, 23] bounds = [14, 23] scale = [1, 0.496714] transformation = TfLinear( bounds[0], bounds[1], thresholds[0], 1, thresholds[1], 0 ) outName = arcpy.env.scratchWorkspace + "\\" + raster.name.replace('Int_Raster','Resc') # Rescale the raster rescaledRaster = RescaleByFunction( raster, transformation, scale[0], scale[1] ) # Save the rescaled raster rescaledRaster.save(outName) print(rescaledRaster.isTemporary) print(rescaledRaster.name)
Rae... could you format your code using python syntax highlighting to make it readable
a duplicate of https://community.esri.com/thread/219450-arcpy-loop-not-saving-rasters
just the OP name is different
Sorry no solution but I have the same problem:
i = 0
#loop through rasters in list
for ir in rrings:
#sum rasters together
if i == 0:
ringSUM = arcpy.Raster(ir)
i += 1
else:
ringSUM = ringSUM + arcpy.Raster(ir)
i += 1
#save final output to the current dirctory
ringSUM.save('C:/SALR_0801/wksp/ringSUMall.tif')
ERROR:
Traceback (most recent call last):
File "C:\SALR_0801\fixCrashSave.py", line 87, in <module>
ringSUM.save('C:/SALR_0801/wksp/ringSUMall.tif')
RuntimeError: ERROR 999998: Unexpected Error.
Sorry that the code is not in python syntax did not copy optimally. The thing for me and wondering if for others is that it seems the raster.save() doesn't work no matter what I have tried. (using variable with path&file, changing to GRID even though I want a TIF, etc).
I want to understand this as I have several other programs to modify and can't seem to get a generic solution. I have lots of disk space and memory running ArcGIS 10.6
Thanks.