AnsweredAssumed Answered

ERROR 000670 with arcpy.Eliminate

Question asked by ludwighilger on Oct 10, 2014
Latest reply on Oct 14, 2014 by curtvprice

Hello Everybody,

 

I have a huge Shapefile in which I want to remove sliver polygons with the eliminate tool in python. However, repeatedly get the following error. At first i tried to execute without the "layer", but otherwise, the "SelectLayerByAttribute_management" returns an error (altough it works with the GUI on the Shapefile directly).

 

I am quite new to ArcGIS scripting and really hope to get some hints.

 

thank you and regards,

Ludwig

 

#################################################################

"File "remove_slivers_and_gaps.py", line 26, in <module>

   arcpy.Eliminate_management(in_features = "layer", out_feature_class = output

shapefile, selection = "AREA", ex_where_clause = ' "Vegetation" = 5 ')

File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\management.py", line 4233, in Eliminate

   raise e

arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.

ERROR 000670: output Output Feature Class is same as input Input Layer

failed to execute (Eliminate)."

################################################################

My Script ist here:

inputshapefile = "Vegetation_25832.shp"
workshapefile = "work_25832.shp"
outputshapefile = "Vegetation_rsag_25832.shp"
env.workspace = "D:\\R_working_directory\\remove_gaps_slivers"

### Repair geometry
arcpy.RepairGeometry_management(in_features = inputshapefile)

### Multipart to Singlepart
arcpy.MultipartToSinglepart_management(in_features = inputshapefile, 
    out_feature_class = workshapefile)

### Add new Field for area
arcpy.AddField_management(in_table = workshapefile, field_name = "area", 
  field_type = "FLOAT", field_precision = 10, field_scale = 2)

### Calculate new Field with area
arcpy.CalculateField_management(in_table = workshapefile, 
  field = "area", expression = '!shape.area@meters!', expression_type = "PYTHON")

### Execute SelectLayerByAttribute to define features to be eliminated
arcpy.MakeFeatureLayer_management(in_features = workshapefile, out_layer = "layer")
arcpy.SelectLayerByAttribute_management(in_layer_or_view = "layer", 
  selection_type = "NEW_SELECTION", where_clause = ' "area" < 1 ')

### Execute Eliminate
arcpy.Eliminate_management(in_features = "layer", out_feature_class = outputshapefile, 
  selection = "AREA", ex_where_clause = ' "Vegetation" = 5 ')

 

Message was edited by: Curtis Price - added python code highlighting and wrapped some lines

Outcomes