1

I'm trying to multiply my raster to 100 from my ListRasters. I've adapted the code (especially the for loop portion) also from this site. Now, I'm encountering an error at the last line, when saving the raster.

How can I successfully run this code?

 #import the module
 import arcpy
 from arcpy.sa import *
 from arcpy import env
 arcpy.CheckOutExtension("Spatial")
 env.overwriteOutput = True
 #set the workspace
 arcpy.env.workspace = r"C:\Users\Windows\Documents\JO_GIS_Analyst"
 #Create a list of raster files
 rasterList = arcpy.ListRasters("reprojected*", "TIF")
 #Loop through the list of ListRaster
 for k in rasterList:
 print k #check the presence of rasters
 OutRaster = (k)*100) #multiplying the raster by 100
 OutRaster_Name = "nofpt" + k #specifying the output name
 OutRaster.save(OutRaster_Name) #saving the raster 
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Aug 7, 2014 at 12:22

1 Answer 1

5

I believe the problem is that the code trying to multiply the name of the raster, rather than the raster itself. Try:

for k in rasterList:
 print k #check the presence of rasters
 OutRaster = Raster(k)*100 #multiplying the raster by 100
 OutRaster_Name = "nofpt" + k #specifying the output name
 OutRaster.save(OutRaster_Name) #saving the raster 
answered Aug 7, 2014 at 12:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.