GraduatedSymbolsRenderer

Resumen

The GraduatedSymbolsRenderer class represents the graduated symbols renderer definition that shows qualitative differences in feature values using a range of symbol sizes.

Debate

The properties behave in a similar manner to the options exposed in the application. For example, changing the number of classes will automatically adjust the break values and their labels. If you change upperBound of a ClassBreak, the classificationMethod automatically changes to ManualInterval. You also need to manually update the labels and/or descriptions properties accordingly.

Propiedades

PropiedadExplicaciónTipo de datos
backgroundSymbol
(Lectura y escritura)

A symbol that represents the background symbol for the features in the layer. It only applies to polygon feature classes.

Symbol
breakCount
(Lectura y escritura)

An integer that represents the number of classes to be used with the current classification method.

Integer
classBreaks
(Lectura y escritura)

A list of ClassBreak objects that provides access to individual properties such as label and description as well as individual symbol objects.

List
classificationField
(Lectura y escritura)

A string that represents a valid field name used for the layer's classification method.

String
classificationMethod
(Lectura y escritura)

A string that represents a valid classification method. The valid values are as follows:

  • DefinedIntervalDefined Interval
  • EqualIntervalEqual Interval
  • GeometricIntervalGeometric Interval
  • ManualIntervalManual Interval
  • NaturalBreaksNatural Breaks (Jenks)
  • QuantileQuantile
  • StandardDeviationStandard Deviation
String
colorRamp
(Lectura y escritura)

Provides access to the ColorRamp object.

ColorRamp
deviationInterval
(Lectura y escritura)

A double that represents a valid deviation interval that is only available if the classificationMethod is set to StandardDeviation. Valid values are 1.0, 0.5, 0.333, and 0.25. These are the same options available in the application.

Double
intervalSize
(Lectura y escritura)

A double that represents an interval size that is only available if the classificationMethod is set to DefinedInterval. Valid values are 1.0, 0.5, 0.333, and 0.25. These are the same options available in the application.

Double
lowerBound
(Lectura y escritura)

A double that represents the minimum value of the symbolized classificationField to be displayed.

Nota:

The value of the lowerBound should only be set to a value within the range of the first class break, otherwise it will fail. The maximum value gets modified in the last class break by changing the upperBound property.

Double
maximumSymbolSize
(Lectura y escritura)

A double that represents the size of the largest graduated symbol.

Double
minimumSymbolSize
(Lectura y escritura)

A double that represents the size of the smallest graduated symbol.

Double
normalizationField
(Lectura y escritura)

A string that represents a valid layer field name that is used for normalization.

String
normalizationType
(Lectura y escritura)

A specific string that represents a valid normalization key word. For example, to clear the normalization, try gradSymbols.renderer.nomalizationType = "<None>".

  • <None>No normalization
  • <percentage of total>Percentage of total
  • <log>Log
String
symbolTemplate
(Sólo lectura)

Returns a symbol that represents the symbol template for all the features in the layer. To set the template use the updateSymbolTemplate method.

Symbol
type
(Sólo lectura)

Returns a string that represents the renderer type.

String

Descripción general del método

MétodoExplicación
updateSymbolTemplate (symbol_template)

updateSymbolTemplate provides a mechanism to change the renderer's symbol template.

Métodos

updateSymbolTemplate (symbol_template)
ParámetroExplicaciónTipo de datos
symbol_template

A reference to a symbol.

(El valor predeterminado es None)

Object

The updateSymbolTemplate method allows you to modify the symbol for all the class breaks at once. The symbol template is managed in the application differently than other renderer properties, for example, backgroundSymbol, and therefore requires a method to set the symbol template to the renderer.

Muestra de código

GraduatedSymbolsRenderer example 1

The following script first tests if the layer's symbology supports a renderer property. It then confirms if the renderer is a GraduatedSymbolsRenderer. Next, it sets up the backgroundSymbol and symbolTemplate. Next, it changes the classificationField and breakCount and also sets the minimum and maximum symbol sizes. Finally, it changes ColorRamp to a color ramp named Black to White.

import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])

p = arcpy.mp.ArcGISProject(relpath + r"\\GraduatedSymbols.aprx")
m = p.listMaps("Layers")[0]
l = m.listLayers("Natural*")[0]
sym = l.symbology

if hasattr(sym, 'renderer'):
  if sym.renderer.type == "GraduatedSymbolsRenderer":
    #set background symbol
    sym.renderer.backgroundSymbol.applySymbolFromGallery("Extent Transparent Wide Gray")
    #set symbol template
    symTemp = sym.renderer.symbolTemplate
    symTemp.applySymbolFromGallery('Square 1')
    sym.renderer.updateSymbolTemplate(symTemp)
    #modify graduated symbol renderer
    sym.renderer.classificationField = "Shape_Area"
    sym.renderer.breakCount = 6
    sym.renderer.minimumSymbolSize = 10
    sym.renderer.maximumSymbolSize = 25
    sym.renderer.colorRamp = p.listColorRamps("Black to White")[0]

    l.symbology = sym
p.saveACopy(relpath + r"\\SavedOutput.aprx")
GraduatedColorsRenderer example 2

The following script modifies the lowerBound and upperBound property values for the renderer's symbolized classificationField. It also uses Python CIM access to display the out of range classificationField values using a default symbol that is automatically generated.

p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('LowerBoundResult')[0]
l = m.listLayers()[0]
if hasattr(l.symbology, 'renderer'):
  if l.symbology.renderer.type == 'GraduatedColorsRenderer':
    sym = l.symbology
    #Set lowerBound set on Renderer
    sym.renderer.lowerBound = 5
    #Set upperBound set on upper ClassBreak
    sym.renderer.classBreaks[-1].upperBound = 96 
    l.symbology = sym

    #Show values out of range using Python CIM Access
    l_cim = l.getDefinition('V3')
    l_cim.renderer.useDefaultSymbol = True
    l_cim.renderer.defaultLabel = "Out of range"
    l.setDefinition(l_cim)