I have a feature class containing sample results for locations that includes thousands of records. Many of these are overlapping and have the same location ID. I need to label each sample based on the most recent sampled date for each unique location ID. Is this possible using a definition query?

I'm using ArcGIS Pro.


1 Answer 1


Similar to suggestion in comments, this expression will do a job:

import datetime
from datetime import datetime
lyr ="BORES";dLabels={};fidKeys={}
with arcpy.da.SearchCursor(lyr,["OBJECTID","SHAPE@XY","MUID"]) as cursor:
  for FD,shp,LABEL in cursor:
    XY=shp; fidKeys[int(FD)]=XY
def FindLabel ( [OBJECTID] ):
  d=int( [OBJECTID])
  return dLabels[aKey]

Each point shown, has 31 spatial duplicate: enter image description here

and it is tested on 1248 points. I've noticed less than a second delay for labeling.

So, call your layer "BORES" with source in FGDB, call date field "MUID" or change code above to suit your naming. Pick explicit location for label, e.g. "right only". Untick "Place overlapping labels" option.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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