I'm trying to write a script in arcpy which reclassified a List of Rasters. This rasters are made by another tool before so there is already a loop. Actually I get the error 000582 and before this the script could reclassify but overwrote the rasters. In the end I like to count the pixel with the value 1 so that I create one raster with the sum of the value 1 as pixelvalue. How can I do this and what is wrong with the following script? Do I need the tool “plus” at the end?
import arcpy
import os
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
env.overwriteOutput = True
env.workspace = r"D:\Julia_T\projekt\aufgabe3\testdatenA"
Dir = env.workspace
#folder to list
ascFileList = arcpy.ListFiles("*.asc")
print ascFileList
for ascFile in ascFileList:
#geoprocessing steps
ascFileName = os.path.splitext (ascFile)[0]
print ascFileName
#works
rastFile = ascFileName + "_output.img"
print rastFile
#works
#run the tool
arcpy.ASCIIToRaster_conversion (env.workspace + "\\" + ascFile, env.workspace + "\\" + rastFile, "INTEGER")
# Process: Projektion definieren
arcpy.DefineProjection_management (env.workspace + "\\" + rastFile, "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRI MEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]")
#list raster
rasters = arcpy.ListRasters("*", "IMG")
for ras in rasters:
print "working..." + ras #works
# new name
name = "class_" + ras
# Recalssify
reclassField = "Value"
remap = RemapValue ([["8",1],["2",0],["5",0]])
outReclassify = Reclassify(ras, reclassField, remap, "NODATA")
#save
outReclassify.save (Dir + "\\" + name)
# Execute Plus
#outPlus = Plus(inRaster1, inRaster2)
I'm working with ArcMap 10.2.1.