import arcpy
def find_overlaps(input_features, output_features):
uniqueList = []
for row in arcpy.da.SearchCursor(input_features, ('OBJECTID', 'SHAPE@', 'name')):
foundMatch = False
for row2 in uniqueList:
if row[1].equals(row2[1]):
foundMatch = True
break
if foundMatch == False
uniqueList.append(row)
return uniqueList
## no work ##
arcpy.management.CopyFeatures(uniqueList, output_features)Perhaps SelectLayerByAttribute to get your selection, then CopyFeatures is a better alternative?
http://resources.arcgis.com/en/help/main/10.1/index.html#//001700000071000000
Unfortunately the 'ARE_IDENTICAL_TO' in Select wasn't picking up any of my duplicate geometries in my test set...(go, fig. Maybe floating point error? They are lines). I tested in both GUI and code. This was the only way to grab them...
Nothing after your return is run. Return basically ends the function.
import arcpy
def find_overlaps(input_features, output_features):
uniqueList = []
for row in arcpy.da.SearchCursor(input_features, ('OBJECTID', 'SHAPE@', 'name')):
foundMatch = False
for row2 in uniqueList:
if row[1].equals(row2[1]):
foundMatch = True
break
if foundMatch == False
uniqueList.append(row)
## no work ##
arcpy.management.CopyFeatures(uniqueList, output_features)
Yes you will need to make your features a layer of some sort before you copy them out. It will not accept a raw list of features as tuples. A better way to go about this might be to use an insert cursor.
Just trying to follow...you mean use an InsertCursor instead of SearchCursor?
template_query = '''{0} < 0'''.format(
arcpy.AddFieldDelimiters(input_fc, arcpy.Describe(input_fc).OIDFieldName))
arcpy.TableToTable_conversion(input_fc, out_dir, output_fc, template_query)import arcpy
def find_overlaps(input_features, output_features):
template_query = '''{0} < 0'''.format(
arcpy.AddFieldDelimiters(input_features, arcpy.Describe(input_features).OIDFieldName))
arcpy.FeatureClassToFeatureClass_conversion(
input_features, out_dir, output_features, template_query)
field_list = ('OBJECTID', 'SHAPE@', 'name')
with arcpy.da.InsertCursor(input_features, field_list) as insert_cursor:
uniqueList = []
for row in arcpy.da.SearchCursor(input_features, field_list):
for shape in uniqueList:
if row[1].equals(shape):
foundMatch = True
break
if not foundMatch:
insert_cursor.insertRow(row)
uniqueList.append(row[1])