Getting aspect and reclassifying raster files using Python in a loop

المشرف العام

Administrator
طاقم الإدارة
By using Python in PythonWin 2.7.3, I tried to obtain aspect files of a list of raster files in a folder(called database_Dem20) and save it to another folder, database_Dem20/testOutput.In the same loop, after getting the aspect file, i want to reclassify this aspect file by using reclassify toolbox.

The first part, getting aspect, is doing fine. However, the reclassify part has error, ERROR 000622: Failed to execute (Reclassify). Parameters are not valid.

I have read the syntax from Esri website for many times and tried to type in different ways but still couldn't figure out where is wrong.

Can anyone help me, please?

Here is my Python scripts:

# Import arcpy moduleimport arcpyfrom arcpy import envimport osfrom arcpy.sa import *# Check out any necessary licensesarcpy.CheckOutExtension("spatial")arcpy.env.overwriteOutput = True # Set Geoprocessing environmentsenv.workspace = "C:\\database_Dem20"targetWorkspace = "C:\\database_Dem20\\testOutput"print "==============================NEW START================================"# Process: Aspect# Get and print a list of TIFs from the workspacerasters = arcpy.ListRasters("*", "TIF")for raster in rasters: inRaster = raster outAspect = Aspect(inRaster) outAspect.save(targetWorkspace + "\\AA_" + inRaster) print("------------------------Reclassify---------------------------------------") # Process: Reclassify inAspect = str(outAspect) remap = RemapRange([[-1, -9.9999999999999995e-007, 1],[-9.9999999999999995e-007, 22.5, 2],[22.5, 67.5, 3],[67.5, 112.5, 4],[112.5, 157.5, 5],[157.5, 202.5, 6],[202.5, 247.5, 7],[247.5, 292.5, 8],[292.5, 337.5, 9],[337.5, 360, 10]]) outReclassify = Reclassify(inAspect, "Value", remap ,"NODATA") outReclassify.save(targetWorkspace + "\\BB_" + inAspect) print("-------------------------Reclassify--------------------------------------")del rasterdel rasters

أكثر...
 
أعلى