Select to view content in your preferred language

Combine labels for nearby/similar features using label expression

323
0
09-18-2023 01:28 PM
EOrd
by
New Contributor

I want to be able to merge/combine labels for nearby features into a single callout. I have created a function that searches all the entries in the layer and returns the combined string I am looking for. However, when I try to add this code to the label expression, the expression is validated, but no labels are displayed (labeling is turned on). I backtracked to see what was causing the issue, and it seems like even just including the line 'aprx = arcpy.mp.ArcGISProject("CURRENT")' is causing an issue. What I really need is to point to the layer in order to access the full set of values. Is there a way to do that within the label expression? Thanks

import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps('Map')[0]
lyr = m.listLayers('SampleMaster')[0]
values = [row[0] for row in arcpy.da.SearchCursor(lyr, 'Well_ID')]

def FindLabel ( [Well_ID] ):
    return Well_ID

 

Tags (2)
0 Kudos
0 Replies