0

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.

0

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

import datetime
from datetime import datetime
BC=datetime(1899,1,1)
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
    latest=dLabels.get(XY,BC);dLabels[XY]=max(latest,LABEL)
def FindLabel ( [OBJECTID] ):
  d=int( [OBJECTID])
  aKey=fidKeys[d]
  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, privacy policy and cookie policy

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