Resumen
The SimpleRenderer class represents a simple renderer that draws all features in a layer with a common symbol.
Debate
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.
Propiedades
Propiedad | Explicación | Tipo de datos |
description (Lectura y escritura) | Gets and sets the description for the simple symbol renderer. | String |
label (Lectura y escritura) | Gets and sets the label for the simple symbol renderer. | String |
symbol (Lectura y escritura) | Gets and sets the symbol associated with the simple symbol renderer. | Symbol |
type (Sólo lectura) | Returns a string that represents the renderer type. | String |
Muestra de código
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'))