updateSymbolTemplate
汇总
UnclassedColorsRenderer 类使用未分类的颜色梯度绘制数量。
讨论
这些属性的行为类似于应用程序中显示的选项。例如,更改 field 将自动调整上下标注。如果更改 expression , field 会自动更改为 Custom 。
语法
updateSymbolTemplate()
属性
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
colorRamp (读取和写入) |
提供对 ColorRamp 对象的访问权限。 |
ColorRamp |
|
expression (读取和写入) |
一个字符串,表示有效的 SQL 表达式。应用表达式时, 符号系统 窗格中的字段名称将显示为 自定义 。 |
String |
|
field (读取和写入) |
一个字符串,表示用于设置未分类颜色且以数字定义的有效字段名称。值 无 可以存在,但是,必须将其更改为有效字段名称,渲染器才能对其进行正确显示。 |
String |
|
lowerLabel (读取和写入) |
一个字符串,表示显示在 内容 窗格或图例中的下标注。 |
String |
|
normalizationField (读取和写入) |
一个字符串,表示用于归一化且以数字定义的有效字段名称。 |
String |
|
symbolTemplate (只读) |
返回表示图层中所有要素的符号模板的 符号 。要设置模板,请使用 |
Symbol |
|
type (只读) |
返回表示渲染器类型的字符串。 |
String |
|
upperLabel (读取和写入) |
一个字符串,表示显示在 内容 窗格或图例中的上标注。 |
String |
方法
updateSymbolTemplate(symbol_template)
updateSymbolTemplate 提供一种可更改渲染器符号模板的机制。
| 名称 | 说明 | 数据类型 |
|---|---|---|
|
symbol_template |
引用 符号 。 (默认值为 None) |
Object |
代码示例
以下脚本首先测试图层的符号系统是否支持 renderer 属性。然后,确认渲染器 type 是否为 UnclassedColorsRenderer 。接下来,修改基本属性,例如字段和标注。随后,应用名为 黄色到红色 的系统 ColorRamp 。最后,使用名为 黑色轮廓(1 磅) 的库符号修改 symbolTemplate 。
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('UnclassedColors')[0]
l = m.listLayers('States_WithRegions')[0]
if l.isFeatureLayer:
sym = l.symbology
if hasattr(sym, 'renderer'):
if sym.renderer.type == 'UnclassedColorsRenderer':
#modify basic properties
sym.renderer.field = "POP2010"
sym.renderer.normalizationField = "Shape_Area"
sym.renderer.lowerLabel = "Upper: " + sym.renderer.lowerLabel
sym.renderer.upperLabel = "Lower: " + sym.renderer.upperLabel
#Modify color ramp
cr = p.listColorRamps('Yellow to Red')[0]
sym.renderer.colorRamp = cr
#Modify the symbol template
symTemp = sym.renderer.symbolTemplate
symTemp.applySymbolFromGallery('Black Outline (1pt)')
sym.renderer.updateSymbolTemplate(symTemp)
l.symbology = sym