1

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)
radouxju
50.2k2 gold badges72 silver badges144 bronze badges
asked Jul 12, 2016 at 9:06
1
  • 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 ? Commented Jul 12, 2016 at 11:01

1 Answer 1

2

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 )
answered Jul 12, 2016 at 10:58
0

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.