I am trying to multiply a list of GRID raster datasets using a different value for each raster. The value is in the raster name. Some examples are [wse_1979_5,wse_1980_0,wse_1980_5], where 1979_5, 1980_0, and 1980_5 will become 1979.5, 1980.0, and 1980.5. Every raster currently is classified where VALUE = 1 for all cells, and multiplying by the above values from the names should make the raster datasets equal to those values. So far I have:
arcpy.env.workspace = *path* from arcpy.sa import * rasters = arcpy.ListRasters() for raster in rasters: multValue = float(raster[4:-2]+"."+raster[-1]) outRaster = raster * multValue outRaster.save(raster+"_r") TypeError: can't multiply sequence by non-int of type 'float'
I am getting "TypeError: can't multiply sequence by non-int of type 'float'". I believe I need to somehow iterate the raster since it is apparently a string(?), but I'm not positive and can't quite figure this one out. It is simple to do in raster calculator, but I have a lot of datasets to multiply.