1

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.

2
  • Https://gis.stackexchange.com/questions/156140/…
    – FelixIP
    Commented Sep 7, 2019 at 1:13
  • 1
    This is far easier if the data is in an enterprise database, since the required window function is a part of the RDBMS. Please edit the question to specify the format(s) of the data source(s).
    – Vince
    Commented Sep 7, 2019 at 1:39

1 Answer 1

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.

1

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.