I am attempting to move away from Coverages. One of the tools we have did a great job of eliminating slivers from our datasets based on hard and soft boundaries for elimination rulesets; howver, it is programmed in AML and utilizes coverages.
I am working on coding this to Python and have some theory/process questions that I need answered. I have run eliminate in the polygon world before and have found that I needed to do the eliminate multiple times in order to eliminate all slivers. This is due to the fact that there might be multiple slivers adjacent to each other and the elimination process can only remove one of them at a time. In AML, simply, arcs are removed of the polygon shapes that meet the criteria making this a non-issue. So, in the past, I have just iterated through the same eliminate function using the output as the new input until I did not see a reduction in table row counts.
Here is my theory on how to process my datasets so far:
import arcpy, os, sys
from arcpy import env
print 'Starting....'
env.OverWriteOutput = True
import datetime
import time
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
print st
fcName = 'C:\David\Eliminate\El_20150122\TSA_PE_L3.shp'
TheLayer = 'C:\David\Delete\ListTest\TheLayer.shp'
OutputLOC = "C:\David\Delete\ListTest\"
myList = set([row.getValue('F_DEL') for row in arcpy.SearchCursor('C:DavidEliminateEl_20150122TSA_PE_L3.shp', fields='F_DEL')])
FCLayer = "C:\David\Delete\ListTest\FCLayer.lyr"
FCsLayer = "C:\David\Delete\ListTest\FCsLayer.lyr"
TheEX2 = "C:\David\Delete\ListTest\TheEX2.lyr"
TableView = "C:\David\Delete\ListTest\TableView.lyr"
Output = "C:\David\Delete\ListTest\Output.shp"
print 'Deleteing existing layers'
if arcpy.Exists(FCLayer):
arcpy.Delete_management(FCLayer)
if arcpy.Exists(OutputLOC + "Exclude.shp"):
arcpy.Delete_management(OutputLOC + "Exclude.shp")
if arcpy.Exists(TheLayer):
arcpy.Delete_management(TheLayer)
if arcpy.Exists(TheEX2):
arcpy.Delete_management(TheEX2)
arcpy.MakeFeatureLayer_management(fcName, FCLayer)
print 'Selecting blocks for creating the hard boundary exclusion layer'
arcpy.SelectLayerByAttribute_management(FCLayer, "NEW_SELECTION", " "BLOCKS" <> ''")
arcpy.FeatureClassToFeatureClass_conversion(FCLayer, OutputLOC, "Exclude")
arcpy.SelectLayerByAttribute_management(FCLayer, "CLEAR_SELECTION")
Name4 = OutputLOC + "Exclude.shp"
arcpy.MakeFeatureLayer_management(Name4, TheEX2) # last input into eliminate
print 'Finished creating exclusion layer'
print 'Creating copy of dataset for elimination'
arcpy.FeatureClassToFeatureClass_conversion(fcName, OutputLOC, "TheLayer")
#myList = set([row.getValue('F_DEL') for row in arcpy.SearchCursor("'"+Name2+"'", fields='F_DEL')])
print 'Finished creating layer'
print 'Working on elimination of slivers'
for a in myList:
#print '"F_DEL"= {}'.format('"'+a+'"')
#break
Last = 1
Count = 2
while Count <> Last:
print "Count = " + str(Count) + ", and Last = " + str(Last)
Count = Last
if arcpy.Exists(FCsLayer):
arcpy.Delete_management(FCsLayer)
arcpy.MakeFeatureLayer_management(TheLayer, FCsLayer)
if arcpy.Exists(Output):
arcpy.Delete_management(Output)
arcpy.SelectLayerByAttribute_management(FCsLayer, "NEW_SELECTION", " "AREAHA" <= 0.1")
arcpy.SelectLayerByAttribute_management(FCsLayer, "REMOVE_FROM_SELECTION", " "BLOCKS" <> ''")
arcpy.Eliminate_management(FCsLayer, Output, "AREA", '"F_DEL" = {}'.format("'" + a + "'"), TheEX2)
arcpy.Delete_management(TheLayer)
arcpy.CopyFeatures_management(Output, TheLayer)
if arcpy.Exists(TableView):
arcpy.Delete_management(TableView)
arcpy.MakeTableView_management(TheLayer,TableView)
Last = arcpy.GetCount_management(TableView)
ts2 = time.time()
st2 = datetime.datetime.fromtimestamp(ts2).strftime('%Y-%m-%d %H:%M:%S')
print st2
break
So this script is working but it is taking forever and will not get out of the While loop when LAST = COUNT. Are there any ways to improve the processing time of this? This is still working on one group of F_DEL to which there are 11 and then once this test is complete I will be iterating this on 12 different layers (12 layers X 11 hours per layer = 7 days of processing). In coverage world this would process in 2 hours.