I am working on an ArcGIS code where I am looping through multiple images in a folder. I see the files are looping in the project folder (when each image is processed a temporary file comes up but they disappear after that image's processing is complete) but only the last image in the folder saves. I have the save function written in the code but it doesn't actually save. Previously I was able to get this portion of the code to save multiple folders before I added the rename line, but I need the files to contain the original name. Could someone please help me with what I am missing? My code is below:
import arcpy
import os
import glob
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
env.workspace = r"E:\\GIS\\LoopTest3"
arcpy.env.extent = r"E:\\Quads.shp"
indef_file = "C:\\Users\\kmcnul1\\Desktop\\SnowClassificationScheme2.ecd"
inRasters = glob.glob(r"E:\\LoopImagesTest\\*.tif")
inMaskData = "Quads"
extraction_area = "OUTSIDE"
analysis_extent = "Quads"
for inRaster in inRasters:
outExtractByMask = ExtractByMask(inRaster, inMaskData)
classifiedraster = ClassifyRaster(outExtractByMask, indef_file)
classifiedraster.save = (r"E:\\GIS\\LoopTest3")
newname = inRaster + "CF"
arcpy.management.Rename(classifiedraster,newname)
What I want to add after is:
ClassRasts = glob.glob(r"E:\\GIS\\LoopTesLoop3\\*.crf")
for ClassRast in ClassRasts:
outCellstats = CellStatistics(ClassRast, "SUM")
outCellstats.save(r"E:\\GIS\\LoopTest3")
arcpy.conversion.ExportTable("FinalCellStat", r"E:\\GIS\\LoopTest3 '', "NOT_USE_ALIAS", 'VALUE "VALUE" true true false 0 Long 0 0,First,#,FinalCellStat,VALUE,-1,-1;COUNT "COUNT" true true false 0 Double 0 0,First,#,FinalCellStat,COUNT,-1,-1', None)
arcpy.conversion.TableToExcel("FinalCellStat_ExportTable", r"E:\\GIS\\LoopTest3\\*.xls", "ALIAS", "CODE")
But I need more than one file folder to save. Ideally, I'd have the last chunk in this loop too, but I was having the same issue with the Cell Statistics only saving the last file in the loop