I have a bunch of data points, which are from Sea-Bird Monitoring.
I need to remove the data points of the sea birds drifting on the ocean to create a heat map for identifying foraging hot spots.
How can I remove the data points that are too close to each other?
Solved! Go to Solution.
Manually:
Python:
points = "TestPoints"
min_dist = 50
# buffer the points and intersect the points with the buffers
# (this is basically what Summaize Nearby does)
buffers = arcpy.analysis.Buffer(points, "memory/buffers", min_dist)
intersects = arcpy.analysis.Intersect([points, buffers], "memory/intersects")
# count the occurence of each ORIG_FID (the point OID) in the intersections
orig_fids = [row[0] for row in arcpy.da.SearchCursor(intersects, ["ORIG_FID"])]
orig_fid_counts = {fid: len([fid1 for fid1 in orig_fids if fid1 == fid]) for fid in orig_fids}
# create a new field in the point layer that stores the count of nearby points
arcpy.management.AddField(points, "NearbyPoints", "LONG")
# calculate that field
with arcpy.da.UpdateCursor(points, ["OID@", "NearbyPoints"]) as cursor:
for oid, np in cursor:
try:
np = orig_fid_counts[oid] - 1
cursor.updateRow([oid, np])
except KeyError:
pass
This will create a new field in your point layer. You only want to include points where that field is 0 in the heatmap. Delete the others or exclude them through selection/definition query.
Manually:
Python:
points = "TestPoints"
min_dist = 50
# buffer the points and intersect the points with the buffers
# (this is basically what Summaize Nearby does)
buffers = arcpy.analysis.Buffer(points, "memory/buffers", min_dist)
intersects = arcpy.analysis.Intersect([points, buffers], "memory/intersects")
# count the occurence of each ORIG_FID (the point OID) in the intersections
orig_fids = [row[0] for row in arcpy.da.SearchCursor(intersects, ["ORIG_FID"])]
orig_fid_counts = {fid: len([fid1 for fid1 in orig_fids if fid1 == fid]) for fid in orig_fids}
# create a new field in the point layer that stores the count of nearby points
arcpy.management.AddField(points, "NearbyPoints", "LONG")
# calculate that field
with arcpy.da.UpdateCursor(points, ["OID@", "NearbyPoints"]) as cursor:
for oid, np in cursor:
try:
np = orig_fid_counts[oid] - 1
cursor.updateRow([oid, np])
except KeyError:
pass
This will create a new field in your point layer. You only want to include points where that field is 0 in the heatmap. Delete the others or exclude them through selection/definition query.
I am trying to do something similar for bus stops. The data has multiple bus stop points for different service providers and for both inbound and outbound direction for the same geographical location. I used the Near tool to locate the stops within 50m distance. The total bus stops are more than 11,000. Is there a smart way to keep only one stop and delete the rest of the points instead of deleting the stops one by one?
Thank you!
I am also trying to do the samething, will let you know if I figure anything out.
I am struggling with this exact same problem. Please let me know if you find a solution!