How to obtain symbology information by feature?

381
2
08-19-2020 12:41 PM
EricEagle
Occasional Contributor III

Assume I have a point layer called "pointlayer" loaded in my active map (ArcGIS Pro).  I set its symbology to a single symbol/color for all points.

I can discover symbology properties by layer easily using Python:

p = arcpy.mp.ArcGISProject('CURRENT')
m = p.activeMap
l = m.listLayers('pointlayer')[0]

sym = l.symbology
print(sym.renderer.symbol.color)

## Result: {'RGB': [76, 230, 0, 100]}

Plain sailing.  However, how would I discover symbol properties per feature?  The documentation examples have only to do with updating a layer's symbology.  However, I'd like to use Python to report RGBA values for each feature in a layer, once a user has already styled it with ArcGIS Pro.

Tags (1)
0 Kudos
2 Replies
DanPatterson
MVP Esteemed Contributor

UniqueValueRenderer—ArcGIS Pro | Documentation 

and a couple of others might offer some hope


... sort of retired...
EricEagle
Occasional Contributor III

Ah, okay.  So I can do something like this:

p = arcpy.mp.ArcGISProject("CURRENT")
m = p.activeMap
l = m.listLayers('pointlayer')[0]
s = l.symbology

for grp in s.renderer.groups:
    for itm in grp.items:
        print(itm.values, itm.symbol.color)

## Result
# [['50']] {'RGB': [0, 0, 3, 100]}
# [['90']] {'RGB': [87, 15, 109, 100]}
# [['100']] {'RGB': [187, 54, 85, 100]}
# [['150']] {'RGB': [250, 141, 9, 100]}
# [['200']] {'RGB': [253, 255, 165, 100]}

It doesn't get to specific rows, but categories should be good enough for this project (better KML exporting).  Thanks!

0 Kudos