I am trying to multiply each raster by coefficient using Map Algebra in Python. I receive the following error for the code below:
calcRaster.save(calcRasterName) AttributeError: 'unicode' object has no attribute 'save'
import arcpy
from arcpy import env
from arcpy.sa import *
env.workspace = r"C:\SomeFolder"
outFolder = r"C:\SomeFolder"
arcpy.CheckOutExtension("Spatial")
rasters = arcpy.ListRasters()
for inRaster in rasters:
calcRaster = inRaster * 720
calcRasterName = outFolder + "/" + calcRaster
calcRaster.save(calcRasterName)
Based on some searching, I redefined the calcRaster variable to:
calcRaster = (Raster(inRaster) * 720)
However, I receive some comments and a new error:
File "C:\Users\rrotz\Desktop\Pycharm\RasterCalculator.py", line 13, in calcRasterName = outFolder + "/" + calcRaster
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\sa\Functions.py", line 4329, in Plus in_raster_or_constant2)
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\sa\Utils.py", line 53, in swapper result = wrapper(*args, **kwargs)
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\sa\Functions.py", line 4326, in Wrapper ["Plus", in_raster_or_constant1, in_raster_or_constant2])
RuntimeError: ERROR 000732: Input Raster: Dataset S:\Group Projects\HDF5\2 Tiff Data\8 Monthly Scaled/ does not exist or is not supported
The last RunTimeError is regarding the outfolder path that I designated for the final calculated rasters.