Hi Jason,Try this code. Set the path of your input data to in_fc. I haven't done anything (other than printing) with the duplicate features - you'll need to use either an insertcursor (with a new empty feature class) or updatecursor (to work with current feature class) to carry over the unique features.Note: I have used two separate cursors on the same feature class. This is due to some issues at 10.0 - at 10.1 one cursor is enough.Let me know if you find any issue or if you need help with creating an output.Thanks, Nobbir
import arcpy in_fc = r"C:\mytools\findidentical\geom_equals.gdb\trailsfew" dsc = arcpy.Describe(in_fc) sr = dsc.spatialReference oid_field_name = dsc.oidFieldName # get a cursor on the input features rows1 = arcpy.SearchCursor(in_fc) # exclude features already compared once exclude = [] # iterate through the first coursor for row1 in rows1: oid1 = row1.getValue(oid_field_name) shp1 = row1.shape # get a second cursor on the same input features rows2 = arcpy.SearchCursor(in_fc) # add the feature to be compared to exclude list exclude.append(oid1) # create a set to hold duplicate features group = set() # iterate through the second cursor for row2 in rows2: oid2 = row2.getValue(oid_field_name) shp2 = row2.shape # ignore features already compared if oid2 in exclude: continue # test equality if shp1.equals(shp2): # add both feature ids to the set of identical features group.add(oid1) group.add(oid2) # add the feature just compared to the exclude list exclude.append(oid2) if group: # if the group is not empty print group
Yes, the answer is "should be". However, in 10.0 (including SP5), digitizing direction mattered. So, the above two lines are considered non-identical 😞 We have enhanced the tool's behavior by ignoring the digitizing direction in 10.1.Let me know if you need a workaround. If you want to try - just look the documentation for ArcPy Geometry classes. There is a method called equals - try using that.Earlier, I was unable to reproduce the case as I was using a 10.1 setup. 😞
Wouldn't a line that starts at vertex 0, goes out to vertex 1, then returns to vertex 0 and closes as vertex 2 (and vertex 2 lies on top of vertex 0 by setting the snapping environment appropriately) be identical by definition?
Thanks for the data 🙂I guess your input to Find Identical is Data_Split_Lines_By_Vertices, right? Here is the screenshot for one of the self-intersecting lines (feat# 5 of your Test_Lines data):[ATTACH=CONFIG]19907[/ATTACH]After splitting this line by vertices, we get 17 short lines.[ATTACH=CONFIG]19909[/ATTACH]None of these 17 lines lie exactly one upon another - that is, there is no spatially duplicate feature among these 17 lines. Could you share your spatially identical lines?
Hi Jason,Could you please share part/all of your data? I have posted some questions to the other thread (on same issue) for you - please respond to the questions - that will help me refine my tests and find a good answer for you. Thanks, NobbirGeoprocessing Team
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.