HOW TO
There are many types of symbology to choose from when symbolizing feature classes, depending on the dataset. One of them is the unique value symbology type that can be based on one or more attribute fields in the dataset. The instructions provided describe how to sort unique value symbology classes using values from a second field in ArcGIS Pro.
Use one of the methods below to sort the unique value symbology classes.
The image below shows the symbology is sorted using values from a second field.
p = arcpy.mp.ArcGISProject('CURRENT') m = p.listMaps('Map')[0] #Update the Map parameter to the Map's name l = m.listLayers('Layer')[0] #Update the Layer parameter to the desired layer #isolate the symbology of the selected layer sym = l.symbology #set the symbology as unique values sym.updateRenderer('UniqueValueRenderer') #specify the desired fields for the symbolizing sym.renderer.fields = ['Field 1', 'Field 2'] #select a colour ramp colorRamp = p.listColorRamps("Cyan to Purple")[0] #set the colour ramp sym.renderer.colorRamp = colorRamp #loop through each of the groups of features for grp in sym.renderer.groups: for itm in grp.items: #Grab the first name in the list transVal = itm.values[0][1] #set the label as the name selected above itm.label = str(transVal) #update the layer symbology l.symbology = sym
The image below shows the symbology is sorted using values from a second field through Python.
Get help from ArcGIS experts
Download the Esri Support App