# How to select the highest points in overlapping point features?

I have a point featureclass with multiple overlapping features. The figure shows two sets of overlapping points--the first set of 2 has values 4 and 6 and the second set of three has values 5, 6, and 7.

How can I select the point with the highest value in each set of overlapping points? I am using ArcGIS and arcpy with the basic license.

• Buffer and dissolve, intersect points with buffers (or spatial join), use summary statistics to find the max value for each case buffer id then join with intersected points by buffer id and select where buffer.Value = sumtable.Value_max. Works best for integer values. Commented Jul 12, 2017 at 21:08
• Dissolve, no multiparts, no fields, statistics max Commented Jul 12, 2017 at 21:28
• Spatial join with INTERSECTS or ARE_IDENTICAL_TO operator as setting field mapping to MAX for the to-be-joined features. Commented Jul 12, 2017 at 22:00
• @faith_dur That seems to do the trick. The problem is, field mappings are a real pain to script.
– Aaron
Commented Jul 14, 2017 at 1:18

Assuming that stacked points have identical XY values, I'd make use of cursors. Tabular methods are faster and cleaner than using spatial tools. First determine which XYs occur more than once in your feature class. Then iterate through the feature class a second time, skipping XYs that occur only once and making use of a dictionary to store previous values. Something like this:

``````#layer name
layer = "LAYER"
#value field
valueField = "Val"

#create list of duplicate xys
xys = set ()
dupXys = set ()
with arcpy.da.SearchCursor (layer, "SHAPE@XY") as curs:
for xy, in curs:
if xy in xys: dupXys.add (xy)

#get oids of highest value XY
xyDi = {}
with arcpy.da.SearchCursor (layer, ["OID@", "SHAPE@XY", valueField]) as curs:
for oid, xy, val in curs:
#skip nonstacked points
if not xy in dupXys:
continue
#check if xy has been added to dictionary
try:
lastOid, lastVal = xyDi [xy]
#if not, add xy to dictionary with oid and val
except:
xyDi [xy] = (oid, val)
#continue cursor
continue
#check if old value is less than current value
if lastVal < val:
#if true, update dictionary
xyDi [xy] = (oid, val)

#create oid sql
path = arcpy.Describe (layer).path
oidFld = arcpy.AddFieldDelimiters (path, arcpy.Describe (layer).OIDFieldName)
oids = [oid for oid, val in xyDi.values ()]
oidStr = ", ".join (map (str, oids))
sql = "{} IN ({})".format (oidFld, oidStr)

#select
arcpy.SelectLayerByAttribute_management (layer, "", sql)
``````
• Many thanks. This finds the max point in a stack, although the final selection only contains the max value points and discards the points that are not stacked.
– Aaron
Commented Jul 14, 2017 at 1:27
• Just skip the first cursor and comment out if not xy in dupXys: continue to select unstacked points. Commented Jul 14, 2017 at 1:30
• Wow, that is a really slick solution and lightning fast from a computational standpoint.
– Aaron
Commented Jul 14, 2017 at 1:36
• Thanks. If you want to select ties you need to get a little fancier, but not much. Right now it just selects the first one it comes across. Commented Jul 14, 2017 at 1:38