SimpleRenderer

Zusammenfassung

The SimpleRenderer class represents a simple renderer that draws all features in a layer with a common symbol.

Diskussion

The renderer in the application that uses this class is called single symbol. You can set basic properties such as label and description that can be useful for controlling how those values appear in a layout legend. This class also exposes the symbol property, which provides access to the Symbol class that allows you to modify the symbol appearance.

Eigenschaften

EigenschaftErläuterungDatentyp
description
(Lesen und schreiben)

Gets and sets the description for the simple symbol renderer.

String
label
(Lesen und schreiben)

Gets and sets the label for the simple symbol renderer.

String
symbol
(Lesen und schreiben)

Gets and sets the symbol associated with the simple symbol renderer.

Symbol
type
(Schreibgeschützt)

Returns a string that represents the renderer type.

String

Codebeispiel

SimpleRenderer example

The following script first confirms that the renderer is SimpleSymbol. It then sets the label and description properties. It finishes by changing the symbol to match an existing symbol in a gallery saved with the project.

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

p = arcpy.mp.ArcGISProject(os.path.join(relpath, 'SingleSymbol.aprx'))
m = p.listMaps('Map')[0]
l = m.listLayers('Airports*')[0]
sym = l.symbology

if sym.renderer.type == 'SimpleRenderer':
  sym.renderer.label = 'Airports'
  sym.renderer.description = 'Nonprimary and Primary'                          
  sym.renderer.symbol.applySymbolFromGallery('Airport')
  sym.renderer.symbol.size = 12
  
  l.symbology = sym

p.saveACopy(os.path.join(relpath, 'SavedOutput.aprx'))