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 arcpy.sa 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
arcpy.CheckOutExtension("Spatial")
# Execute
seg_raster = SegmentMeanShift(inRaster, spectral_detail, spatial_detail, min_segment_size)
# Save the output
seg_raster.save(r"Path:\blah\blah\seg_test.img")
This is the error:
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\sa\Functions.py", line 7783, in SegmentMeanShift
band_indexes)
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\sa\Utils.py", line 53, in swapper
result = wrapper(*args, **kwargs)
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\sa\Functions.py", line 7776, in Wrapper
band_indexes)
File "C:\Program Files (x86)\ArcGIS\Desktop10.4\ArcPy\arcpy\geoprocessing\_base.py", 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.