I'm using the Python window in ArcMap 10.3.1 to conduct Maximum Likelihood classifications (MLClassify, Spatial Analyst extension) on multiple images. I've done this with no issues before, but now when I run the code, the pathnames for some (but not all) of the inputs seem to be altered and cause errors.
Here is sample code I'm running in the Python window that defines my input files and runs the classify tool:
import arcpy from arcpy import env from arcpy.sa import * aug1951_clip_BW = "C:\Project\GIS\Grayscale\GrayAllYears.gdb\aug1951_clip_BW" #input raster aug1951_clip_bw_gsg = "C:\Project\GIS\Grayscale\aug1951_clip_bw.gsg" #signature file, used in classifying Class_aug1951_clip_BW = "C:\Project\GIS\Grayscale\GrayAllYearsNewGSGOutput.gdb\Class_aug1951_clip_BW" #name of output classified image ConClass_aug1951_clip_BW = "C:\Project\GIS\Grayscale\GrayAllYearsNewGSGOutput.gdb\ConClass_aug1951_clip_BW" #name of optional confidence image output arcpy.gp.MLClassify_sa(aug1951_clip_BW, aug1951_clip_bw_gsg, Class_aug1951_clip_BW, "0.0", "EQUAL", "", ConClass_aug1951_clip_BW)
The MLClassify command then fails to execute--interestingly, in the error message that appears, the "\a" in the signature file (.gsg) pathname seems to be replaced with a black dot/bullet point. My guess was that this altered pathname is what renders the file in the argument unrecognizable and causes the following error:
ExecuteError: Failed to execute. Parameters are not valid. ERROR 000865: Input signature file: C:\Project\GIS\Grayscale•ug1951_clip_bw.gsg does not exist. Failed to execute (MLClassify).
However, this doesn't happen with my signature files that do not begin with the letter "A"!
Below, an example of a classification that ran with no errors, identical in all ways besides the input filenames:
sep1979_clip1_BW = "C:\Project\GIS\Grayscale\GrayAllYears.gdb\sep1979_clip1_BW" sep1979_clip1_BW_gsg = "C:\Project\GIS\Grayscale\sep1979_clip1_BW.gsg" Class_sep1979_clip1_BW = "C:\Project\GIS\Grayscale\GrayAllYearsNewGSGOutput.gdb\Class_sep1979_clip1_BW" ConClass_sep1979_clip1_BW = "C:\Project\GIS\Grayscale\GrayAllYearsNewGSGOutput.gdb\ConClass_sep1979_clip1_BW" arcpy.gp.MLClassify_sa(sep1979_clip1_BW, sep1979_clip1_BW_gsg, Class_sep1979_clip1_BW, "0.0", "EQUAL", "", ConClass_sep1979_clip1_BW)
Why is this bullet point inserted in the middle of my signature file pathname/how can I stop this from occurring, and how can I execute MLClassify for these images without having to rename my signature files that begin with "A"? This is the only trend I find in common among the images that have failed to run.