Hello all,
I have written a script to partially automate a supervised classification of a raster (my only interest is to differentiate water features from non-water features) and it worked seamlessly on several tests, but I am now encountering error(s) when I attempt to create signature file(s). I am running ArcGIS 10.2.1 (Advanced)
# Import python modules
import arcpy, os, ntpath
# Input Parameters
classRast = arcpy.GetParameterAsText(0)
trainSamp = arcpy.GetParameterAsText(1)
aPriori = arcpy.GetParameterAsText(2)
outDir = arcpy.GetParameterAsText(3)
#Environments
arcpy.env.workspace = outDir
ws = arcpy.env.workspace
arcpy.env.overwriteOutput = True
def stripped(path):
head, tail = ntpath.split(path)
return tail or ntpath.basename(head)
# Create Signatures from Shoreline Training Samples
arcpy.AddMessage("Generating Signature File from Training Samples...")
sigFile = outDir + "/TrainSignats.GSG"
arcpy.gp.CreateSignatures_sa(classRast,trainSamp,sigFile,"COVARIANCE","Classvalue")
On one failed example, the inputs are:
classRast = m_3307811_ne_17_1_20130929.tif
trainSamp = S:/Software/Scripts and Tools/ShorelineTools/ExtractShorelines.gdb/ShorelineTrainingSamples
aPriori = S:/Software/Scripts and Tools/ShorelineTools/apriori.txt
outDir = T:/PERSONAL/Jimmy/SE USA/test5
I hit an error on line 22 stating:
Traceback (most recent call last):
File "T:\PERSONAL\Jimmy\Tools and References\python scripts\ExtractShorelines.py", line 29, in <module>
arcpy.gp.CreateSignatures_sa(classRast,trainSamp,sigFile,"COVARIANCE","Classvalue")
File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 498, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
ExecuteError: ERROR 010423: T:\PERSONAL\Jimmy\SE USA\test5\t_t285 does not have valid statistics as required by the operation.
ERROR 010159: Unable to open VAT file of t:\personal\jimmy\se~d1mse\test5\t_t285. ClassSig failed!
ERROR 010067: Error in executing grid expression.
Failed to execute (CreateSignatures).
I have tried building pyramids and statistics for the problem raster(s) prior to executing the script. I have also tried the raster(s) into GRID format, but neither of these approaches has changed the result. I have had some tiff rasters succeed but other tiffs fail and so far all jp2 files have failed. The location of the VAT file looks suspect as I'm not sure where the '\se~d1mse' portion of the filepath comes from or what it refers to. Any ideas why the CreateSignatures fails?