Select to view content in your preferred language

Using Python in ArcGIS Pro to Change Layer Symbology

02-23-2022 07:50 AM
New Contributor II

I am trying to change the symbology of a polygon layer in ArcGIS Pro desktop using Python. The layer has already been added to the map. I figured out how to change the symbology of the stroke and fill symbols using CIM. However, that has only worked to change the color of one stroke symbol (polygon outline) and polygon fill. I would like to add a second stroke symbol layer so that the polygon outline will be symbolized with a 2pt width yellow stroke line on top of a 4pt width black stroke line. Is this possible to do? Here is my code so far (note - this only changes symbology for a single stroke line.

p ='current')
m = p.listMaps()[0]
lyr = m.listLayers('Project_Area')[0]
cim_lyr = lyr.getDefinition('V2')
symLvl1 = cim_lyr.renderer.symbol.symbol.symbolLayers[0]
symLvl1.color.values = [255,255,0,100]
symLvl1.width = 4

#Note - Want to add a second stroke symbol with a width of 2pt to draw on top of the other (4pt) stroke symbol

symLvl2 = cim_lyr.renderer.symbol.symbol.symbolLayers[1]
symLvl2.color.values = []

0 Kudos
2 Replies
MVP Esteemed Contributor

Hate to ask, but is there a reason you can't implement this by importing symbology from a lyrx layer file? This would be a lot less work!

0 Kudos
New Contributor II

Thank you for the reply. I'm hoping to be able to change the symbology directly from the script, rather than saving and referencing a bunch of layer files.

0 Kudos