操作方法

操作方法:在 ArcGIS Pro 中使用第二个字段中的值对唯一值符号系统类进行排序

Last Published: September 26, 2023

摘要

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.

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.

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.

文章 ID:000026861

从 ArcGIS 专家处获得帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项

相关信息

发现关于本主题的更多内容