I am desperately looking for solution for one problem. I have one point Shapefile, I need to check if there are any duplicate points nearby (let's say 10 meter).
I am not familiar with ArcObjects, is there any way to do it in Python script.
You would need to use arcpy.Geometry to obtain the geometry objects of the polygons (buffered points - use the Buffer GP tool for that) and points themselves; then find out whether the polygons contains any points that have the same identity (you choose what field to compare).
A quick draft is below; this will give you an idea how to get started. Depending on the size of your dataset, you might need to abandon arcpy at some point and just do the math (point in polygon problem). If you want to stay with arcpy with larger datasets, using Spatial Join GP tool (optionally with spatial indexes) and post-processing output to find out the duplicates is another option.
import arcpy
pnt_fc = r"C:\Default.gdb\_PointDistanceFc"
buff_fc = r"C:\Default.gdb\_PointDistanceFc_Buffer"
identify_field = "identity"
with arcpy.da.SearchCursor(buff_fc,["SHAPE@",identify_field,"PolyID"]) as buff_cur:
for buff in buff_cur:
with arcpy.da.SearchCursor(pnt_fc,["SHAPE@",identify_field,"PntID"]) as pnt_cur:
for pnt in pnt_cur:
if buff[0].contains(pnt[0]) and buff[1] == pnt[1]:
print "polyID {0} contains duplicate".format(buff[2]), " pntID {0}".format(pnt[2])
I'd use integrate tool (Data Management Tool-Feature Class).
You can join 2nd table to original to find 'duplicates' in original
Qicker solution using Spatial Join to itself, one to one, intersect, search radius = 10. Output will have Join_Count = 1 for points with no neighbours, the rest are your "duplicates"
Hi i was able to acheive m goal with selecting nearby points, putting all field value in array and counting the array ocurance and pasting values into another field
fc = r"C:\Akhil_Office_1\Python\test\PATest1.shp"
fields = ["FEATURE_ID", "ADDRESS"]
with arcpy.da.SearchCursor(fc, fields) as cursor:
for row in cursor:
value=row[0] #get value "FEATURE_ID" field - unique value ???
field="FEATURE_ID"
exp=field + "='" +value+"'"
point_lyr=arcpy.SelectLayerByAttribute_management(fc,"NEW_SELECTION",exp)
arcpy.SelectLayerByLocation_management(point_lyr, overlap_type="WITHIN_A_DISTANCE", select_features=point_lyr, search_distance="25 Meters", selection_type="NEW_SELECTION")
occursTwice = []
cursor = arcpy.da.SearchCursor ("PAtest2", ['ADDRESS'])
for row in cursor:
occursTwice.append (row[0])
del cursor
cursor = arcpy.da.UpdateCursor ("PAtest2", ['ADDRESS', 'Dup'])
for row in cursor:
row[1] = occursTwice.count(row[0])
cursor.updateRow(row)
del cursor
del point_lyr
del cursor
this works fine, but this is too slow, it takes one hour for 500 point sometimes get hanged, and i am having huge point file, not less than 100000 points in one, so its not worth.