2

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.

1

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])
  • hi Alex , ur solution works quite well . – Akhil Kumar Aug 28 '15 at 11:41
  • hi Alex , ur solution works well ., but my problem is much more complex. let me try to explain this. i have 100000 point in a shape file contains house numbers in the Field "ADDRESS". the real problem is that i want to find duplicate in it. but not in the entire Shape File. Instead it should pick one point and compare its "ADDRESS" in nearby Point in buffer distance( say 25 Meter). if duplicate found it should update duplicate point number in another field Named "Dup" with a count of duplicates. than move to another point and do the same thing and so on... Thats how it should work.. – Akhil Kumar Aug 28 '15 at 11:50
1

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"

0

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.