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:\David\Eliminate\El_20150122\TSA_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):
if arcpy.Exists(OutputLOC + "Exclude.shp"):
    arcpy.Delete_management(OutputLOC + "Exclude.shp")
if arcpy.Exists(TheLayer):
if arcpy.Exists(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+'"')
    Last = 1
    Count = 2

    while Count <> Last:
        print "Count = " + str(Count) + ", and Last = " + str(Last) 

        Count = Last

        if arcpy.Exists(FCsLayer):
        arcpy.MakeFeatureLayer_management(TheLayer, FCsLayer)
        if arcpy.Exists(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.CopyFeatures_management(Output, TheLayer)

        if arcpy.Exists(TableView):

        Last = arcpy.GetCount_management(TableView)
        ts2 = time.time()
        st2 = datetime.datetime.fromtimestamp(ts2).strftime('%Y-%m-%d %H:%M:%S')
        print st2

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.

enter image description here

  • Have you considered Integrate to remove slivers? resources.arcgis.com/en/help/main/10.2/index.html#//… if you provide a single dataset it 'snaps' to itself and cleans up small gaps. – Michael Stimson Jan 27 '15 at 22:45
  • 1
    I don't think I can use it as listed in resources.arcgis: "You would use Integrate rather than a topology when: You do not need to specify any rules about how features are moved—you simply want all features to coalesce within a specified tolerance." I have lots of rules. – D_C Jan 27 '15 at 23:13
  • Yes, with integrate all close features move, you can assign weights so that less accurate features move more but in the end all features move. Perhaps with your rules you could create a layer with a query and use something like Snap resources.arcgis.com/en/help/main/10.2/index.html#//… – Michael Stimson Jan 27 '15 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.