eibenm

arcpy symbology colors changing on RefreshActiveView()

Discussion created by eibenm on Oct 20, 2013
I have a problem that I'm not sure is a acpy glitch or I'm just doing something wrong.  I'm using arcpy.mapping.UpdateLayer() to apply symbology to a layer, but afterwards some elements of the symbology needs to be removed depending on the attributes of the value field.  I've achived this programmatically, determining which symbology values need to be removed.  I'm using something similar to the following code to remove values from the symbology.

lyr = arcpy.mapping.Layer(<layer name>)

a = lyr.symbology.classValues
b = lyr.symbology.classLabels

a = [u'1', u'2', u'3', u'4', u'5']
b = [u'Low', u'Moderate', u'High', u'Very High', u'Extreme']

a.remove('5')
b.remove('Extreme')

lyr.symbology.classValues = a
lyr.symbology.classLabels = b

arcpy.RefreshActiveView()


The method seems to work great.  The problem is the colors set by the symbology change after the arcpy.RefreshActiveView(), which defeats the whole purpose of applying symbology in the first place.  Is there a way to keep the colors the same after removing symbology values?

Thanks in advance!

Outcomes