I have written a script for a custom tool that gets all the rasters from a geodatabase and then adds them all together.
import arcpy
from arcpy import env
from arcpy.sa import *
workspace = arcpy.GetParameter(0)
SuitabilityRaster = arcpy.GetParameterAsText(1)
rasters = arcpy.ListRasters()
for inRaster in rasters:
SuitabilityRaster = SuitabilityRaster + inRaster
SuitabilityRaster.write(workspace + "SuitabilityScoringGrid_Raster")
When I run the tool it gives the following error: AttributeError: 'str' object has no attribute 'write'
Would be grateful if someone could help explain this and provide a solution? The 'SuitabilityRaster' begins as a constant raster surface with the value of 0 and then 'rasters' is a list of the rasters from the geodatabase that should be sequentially added to the 'SuitabilityRaster' within the for loop.
Thanks.