The function
arcpy.sa.Functions.ClassifyRaster(in_raster, in_classifier_definition, in_additional_raster='#')
is giving me the error RuntimeError: Object: Error in executing tool.
I set up the example analogue to Raster klassifizieren—Hilfe | ArcGIS for Desktop .
You can see the code in the following:
import arcgis
from arcgis.gis import GIS
from arcgis.raster import Raster
import arcpy
from arcpy.sa import *
from arcgis.raster.functions import *
from arcgis.raster.analytics import *
arcpy.CheckOutExtension("Spatial")
file_path = r"<path>.tif"
raster_test = Raster(file_path)
test_img = segment_mean_shift(raster_test, spectral_detail=None, spatial_detail=None, spectral_radius=None, spatial_radius=None, min_num_pixels_per_segment=None)
# file generated through graphical interface, because python code is not working as well
ecd_file = f"<path>/Preview_Segmented_TrainIsoCl.ecd"
ClassifyRaster(in_raster=test_img, in_classifier_definition=ecd_file)
I appreciate any help in solving this issue 😃
ecd_file = f"<path>/....
did you mean
ecd_file = r"<path>/...
or was the 'f' instead of the 'r' a copy issue?
Yeah, it was just a copying issue. Should have been
ecd_file = r"<path>\Preview_Segmented_TrainIsoCl.ecd"
Classify Raster (Spatial Analyst)—ArcGIS Pro | Documentation
# file generated through graphical interface, because python code is not working as well
Not sure what you mean by that, but the warning in the help suggests something appears to be wrong with the inputs in a big way and I can't tell from your code (not sure what all the imports are needed for given the code examples in the help files)
The .ecd file contains all the information needed to perform a specific type of Esri-supported classification. The inputs to this tool must match the inputs used to generate the required .ecd file.
The .ecd file can be generated from any of the classifier training tools, such as Train Random Trees Classifier or Train Support Vector Machine Classifier.