AnsweredAssumed Answered

Spatial Analyst's SegmentMeanShift tool fails in standalone script

Question asked by emblaisdell on Oct 18, 2016
Latest reply on Jan 17, 2018 by Dan_Patterson

In ArcMap 10.4, I can run the SegmentMeanShift tool (Segment Mean Shift—Help | ArcGIS for Desktop ) in the Python window, or from the ArcToolbox, just fine. 


However, when trying to run a standalone script incorporating the tool, I receive the ever-useful "Unexpected Error." 


I am using the standalone tool template as provided in the link above. My Spatial Analyst licenses are valid. I am not using the optional band indexes parameter.

# Import system modules
import arcpy
from import *

# Set local variables
inRaster = r"Path:\blah\blah\master.img"
spectral_detail = "15"
spatial_detail = "15"
min_segment_size = "10"

# Check out the ArcGIS Spatial Analyst extension license

# Execute
seg_raster = SegmentMeanShift(inRaster, spectral_detail, spatial_detail, min_segment_size)

# Save the output"Path:\blah\blah\seg_test.img")

This is the error: 

File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\sa\", line 7783, in SegmentMeanShift
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\sa\", line 53, in swapper
result = wrapper(*args, **kwargs)
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\sa\", line 7776, in Wrapper
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\", line 506, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: ERROR 999998: Unexpected Error.
Failed to execute (SegmentMeanShift).


Again, it works fine within ArcMap. I should say I have gotten it to work in a standalone script before, with different spectral, spatial, and min_size parameters. If it's a problem with the inputs I don't know why it would work within ArcMap.


Any thoughts? Thanks.