Select to view content in your preferred language

Is it possible to batch delete raster statistics?

702
3
10-31-2011 06:04 AM
VinceLegendre
New Contributor II
Does anyone know of a way to batch delete raster statistics like their is to batch create statistics?

Thanks,

Vince
0 Kudos
3 Replies
VinceLegendre
New Contributor II
What I ended up doing was deleting the tif.aux.aml file associated with each image. That was where the information for the raster statistics was stored.
0 Kudos
SusanJones
Occasional Contributor II
Copy and paste into Python file, update the directory variable in the code and run. All aux will be removed in the folder and subFolders.

#smjRemoveStatisticsFromFileImagery.py
#Purpose:
#Remove image statistics from file-based imagert

#import Modules
import string, os, datetime, sys

#banner
print "***\nRemove Image Statistics from Directory and Subdirectories\n***"

#input Parameters

#USER NEEDS TO PROVIDE A DIRECTORY VALUE
directory=r"D:\Temp" #r"c:\temp"

#walk
print "processing" + directory
startTime=datetime.datetime.now()

#walk Through The Subdirectories
print "***Walk:\t" + directory
for src, dirs, files in os.walk(directory):
    #process Each Directory
    wsp=os.path.join(directory, src)
    print "***processing:"+src
    #get Files
    try:
        fls=os.listdir(src)
        for fl in fls:
            #check If Aux File
            if string.find(string.lower(fl),".aux") > -1:
                try:
                        os.remove(os.path.join(wsp,fl))
                except:
                    print "cannot Process " + os.path.join(wsp,fl)
    except:
        print "cannot Process " + wsp
                 
#print Elapsed Time
print "Elapsed Time:" + str(datetime.datetime.now()-startTime)

#complete
print "complete"
0 Kudos
SusanJones
Occasional Contributor II
remember to format with the tabs. all formatting is lost when I copied and pasted.
0 Kudos