I have multiple rasters with range 0 - 255. I want to extract range from 0 to 100 using Arc GIS python script and after extraction I want to multiply all raster by 0.01 and save it with same name as it input using loop function. I have made one script till raster extraction, but I am getting an error while running the script. Below I have shown my script.
import arcpy, os
arcpy.CheckOutExtension('Spatial')
arcpy.env.workspace = r"D:\MODIS-NDVI\FPAR-2005\MASKED-FPAR-05"
outFolder = r"D:\MODIS-NDVI\FPAR-2005\MASKED-FPAR-05A"
arcpy.CheckOutExtension("Spatial")
list = arcpy.ListRasters
for inRaster in rasters:
outRaster = outFolder + "\\" + inRaster
arcpy.sa.con(inRaster >3000,inRaster)
-
welcom to GIS SE. Please add the error message when you post this kind of question. Why is it in your script > 3000 and your text between 0 and 100 ?radouxju– radouxju2016年07月12日 11:01:58 +00:00Commented Jul 12, 2016 at 11:01
1 Answer 1
there are a few things to check, but your error could be a missing indentation, "con" without a capital letter or the missing () after ListRasters. I've replaced some part of your code (not all changes are necessary) and added the save.
import arcpy, os
from arcpy.sa import *
arcpy.CheckOutExtension('Spatial')
arcpy.env.workspace = r"D:\MODIS-NDVI\FPAR-2005\MASKED-FPAR-05"
outFolder = r"D:\MODIS-NDVI\FPAR-2005\MASKED-FPAR-05A"
list = arcpy.ListRasters()
for inRaster in list:
localRaster = Raster(inRaster)
outRaster = Con(localRaster >3000, localRaster*0.01)
outRaster.save(outFolder + "\\" + inRaster )
Explore related questions
See similar questions with these tags.