HOW TO

Sort unique value symbology classes using values from a second field in ArcGIS Pro

Last Published: September 26, 2023

Summary

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.

Procedure

Use one of the methods below to sort the unique value symbology classes.

Edit the symbology from the Symbology pane

  1. In ArcGIS Pro, right-click the feature layer from the Contents pane and click Symbology.
  2. In the Symbology pane, on the Primary symbology tab, select Unique Values under Primary symbology.
  3. Select the first field for Field 1, and click Add field to add the second field.
  4. For Field 2, select the desired symbology field. Change the color scheme if needed.
The Symbology pane with Field 1 and Field 2 to select Unique Values.

The image below shows the symbology is sorted using values from a second field.

The symbology sorted using values from a second field.

Use a Python script in ArcGIS Pro

  1. In ArcGIS Pro, click the Analysis tab on the top ribbon. Click the drop-down menu next to Python and select click Python window.
  2. In the Python window, insert the following commands:
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 
  1. Press Enter two times.

The image below shows the symbology is sorted using values from a second field through Python.

The symbology sorted using values from a second field through Python.

Article ID: 000026861

Software:
  • ArcGIS Pro 2 8 x
  • ArcGIS Pro 2 7 x
  • ArcGIS Pro 2 x

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Related Information

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options