Finding points in specific radius that are closest to point?

I'm trying to find the number of restaurants that lie within 600m of a gym. I've read a post on how to do this: namely generating a near table and summarizing the input feature.

The trouble I'm having is that say there are two gyms, gym A and gym B. If there is a point that is within 600m of both of them, it is in the count for gym A AND gym B. How would I go about making it so that this point is only counted for the gym it is closest to within that 600m radius?

I am using ArcMap over Citrix. 10.3 I think.

• What GIS software are you using? What were your precise steps so far? – PolyGeo Nov 26 '16 at 19:52
• ArcMap over Citrix. 10.3 I think. I generated a near table, with gym points as my input features and restaurant points for my near features and unchecked the box that says, "find only closest feature". Then I then summarized by the input feature by right clicking the In_FID field and choosing to summarize. – J. Doe Nov 26 '16 at 20:00
• Sort table in descending order, delete identical restaurants – FelixIP Nov 26 '16 at 20:10
• The sum produced a table with columns titled: OID, IN_FID, and Count_IN_FID. I don't think I can delete identical restaurants at that point because its just a count. Which table are you thinking of to delete the identical restaurants? The near table? – J. Doe Nov 26 '16 at 20:20
• Please use the edit button beneath your question to revise it with any requested clarifications because potential answerers do not always have time to read comment trails. – PolyGeo Nov 26 '16 at 20:33

1 Answer

``````arcpy.GenerateNearTable_analysis("GYMS", "RESTAURANTS", "..abc","50000000 Meters","NO_LOCATION", "NO_ANGLE", "ALL", "0", method="PLANAR")
arcpy.SelectLayerByAttribute_management("abc", "NEW_SELECTION","NEAR_DIST >=600")
arcpy.DeleteRows_management(in_rows="abc")
arcpy.Sort_management("abc","..SORTED", "NEAR_DIST ASCENDING")
arcpy.AddField_management("SORTED", "COMBO", "TEXT")
arcpy.CalculateField_management("SORTED", "COMBO", """[IN_FID] & " " & [NEAR_FID]""")
arcpy.DeleteIdentical_management("SORTED", "COMBO")
``````