AnsweredAssumed Answered

Arcpy workflow fails to execute

Question asked by oladayiyeas on Sep 20, 2018
Latest reply on Sep 20, 2018 by dkwiens

I have a python workflow created to read image files (in folders) and simply write the raster attributes to a text file. The script runs up to line 7, writes out the header, and aborts without reporting any error. I can't figure out what issues are hidden in lines 8 - 20. I use 10.3.1.

 

import arcpy, sys, os
from arcpy import env
env.workspace = "Z:\..."
root_folder = env.workspace
out_file = open("Z:\....txt","a")
#Next line creates an header to properly identify the properties.
out_file.write("BANDCOUNT"+'\t'+"CATALOGPATH"+'\t'+"COMPRESSIONTYPE"+'\t'+"EXTENT"+'\t'+"FORMAT"+'\t'+"HASRAT"+'\t'+"HEIGHT"+'\t'+"MAXIMUM"+'\t'+"MINIMUM"+'\t'+"ISINTEGER"+'\t'+"MEANCELLHEIGHT"+'\t'+"MEANCELLWIDTH"+'\t'+"NAME"+'\t'+"NODATAVALUE"+'\t'+"PATH"+'\t'+"PIXELTYPE"+'\t'+"SPATIALREFERENCE"+'\t'+"STANDARDDEVIATION"+'\t'+"UNCOMPRESSEDSIZE"+'\t'+"WIDTH"+'\n')
ext = [".bil",".bip",".bsq",".bmp",".flv",".img",".dt0",".dt1",".dt2",".ecw",".img",".raw",".grd",".gif",".hgt",".jpg",".jpeg",".jpc",".jpe",".sid",".view",".png",".tif",".tiff"]
for root, dirs, files in os.walk(root_folder):
    for filename in files:
        if filename.endswith(tuple(ext)):
            try:
                raspath = root + "\\" + filename
                ras = arcpy.Raster(raspath)
                rasDescription = (str(ras.bandCount) +'\t'+ str(ras.catalogPath)+'\t' +str(ras.compressionType)+'\t'+ str(ras.extent)+'\t'+'\t'+'\t'+'\t'+str(ras.format)+'\t'+str(ras.hasRAT)+'\t'+str(ras.height)+'\t'+str(ras.maximum)+'\t'+ str(ras.minimum)+'\t'+str(ras.isInteger)+'\t'+ str(ras.meanCellHeight)+'\t'+str(ras.meanCellWidth)+'\t'+str(ras.name)+'\t'+str(ras.noDataValue)+'\t'+str(ras.path)+'\t'+str(ras.pixelType)+'\t'+str(ras.spatialReference)+'\t'+str(ras.standardDeviation)+'\t'+str(ras.uncompressedSize)+'\t'+str(ras.width))
                out_file.write(rasDescription+'\n')
            except RuntimeError:
                continue 
out_file.flush()
out_file.close()

Outcomes