Hi,
I've been trying to run arcpy.management.Eliminate in a script. As I understand, this tool, uses a layer with a selection in order to "merge" the selection with other adjacent polygons from the same layer.
Regardless of ESRI's doc, I can't seem to be able to make my script work. The problem seem to be the way I pass the feature Layer and selection to the Eliminate tool. I've tried countless ways, but it just doesn't seem to work. The layer is always passed as is and no polygon is merged.
Here is the bit of code that I'm using:
[...]
milieux_boises = arcpy.GetParameterAsText(0)
donnees_ecofor = arcpy.GetParameterAsText(1)
mb_ecofor = fr"{GDB}\mb_ecofor"
arcpy.analysis.Identity(in_features=milieux_boises, identity_features=donnees_ecofor_select, out_feature_class=mb_ecofor)
mb_ecofor_split = fr"{GDB}\mb_ecofor_split"
arcpy.MultipartToSinglepart_management(in_features=mb_ecofor, out_feature_class=mb_ecofor_split)
mb_ecofor_split_select="mb_ecofor_split_select"
arcpy.management.MakeFeatureLayer(in_features=mb_ecofor_split, out_layer=mb_ecofor_split_select)
exp = "FID_{0}= -1".format(nom_ecof)
arcpy.management.SelectLayerByAttribute(in_layer_or_view=mb_ecofor_split_select, selection_type="NEW_SELECTION", where_clause=exp, invert_where_clause=None)
mb_ecofor_split_net = fr"{GDB}\mb_ecofor_split_net"
arcpy.management.Eliminate(in_features=mb_ecofor_split_select, out_feature_class=mb_ecofor_split_net, selection="LENGTH") [...]
The most frustrating part is that if I run the exact same lines in the python windows of ArcGIS Pro, it works.
Does anyone have a clue how to fix this?