Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Update layer symbology with arcpy
import json
import arcpy
def resize_symbol(layer):
if not layer.isFeatureLayer:
return
symbology = json.loads(layer._arc_object.getsymbology())
if symbology['renderer']['type'] == 'simple':
if symbology['renderer']['symbol']['style'] == 'esriSMSCircle':
symbology['renderer']['symbol']['size'] *= 3
if symbology['renderer']['symbol']['style'] == 'esriSLSSolid':
symbology['renderer']['symbol']['width'] *= 3
else:
for break_symbols in symbology["renderer"]["uniqueValueInfos"]:
if break_symbols['symbol']['style'] == 'esriSMSCircle':
break_symbols['symbol']['size'] *= 3
if break_symbols['symbol']['style'] == 'esriSLSSolid':
break_symbols['symbol']['width'] *= 3
layer.updateLayerFromJSON(json.dumps({'drawingInfo': symbology}))
layers = arcpy.mapping.ListLayers(arcpy.mapping.MapDocument('CURRENT'))
for layer in layers:
resize_symbol(layer)
arcpy.RefreshActiveView()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.