Resumen
Represents a raster classify colorizer.
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 the upperBound property of a RasterClassBreak, the classificationMethod automatically changes to ManualInterval. You would also need to manually update the labels property accordingly.
Propiedades
Propiedad | Explicación | Tipo de datos |
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 RasterClassBreak objects that provides access to individual properties such as label and color. | 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:
| String |
colorRamp (Lectura y escritura) | Provides access to the ColorRamp object. | ColorRamp |
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 |
noDataColor (Lectura y escritura) | A Boolean that controls the display of missing values. If True missing values are displayed. | Dictionary |
type (Sólo lectura) | Returns a string that represents the renderer type. | String |
Muestra de código
The following script first tests if the layer's symbology supports a colorizer property and then confirms if the renderer is a RasterClassifyColorizer. Next. it changes the classificationField and breakCount. Finally, it changes ColorRamp to a color ramp named Cyan to Purple.
import arcpy
import os
import sys
relpath = os.path.dirname(sys.argv[0])
p = arcpy.mp.ArcGISProject(relpath + r'\\RasterClassify.aprx')
m = p.listMaps('Map')[0]
l = m.listLayers('Raster1')[0]
sym = l.symbology
if hasattr(sym, 'colorizer'):
if sym.colorizer.type == 'RasterClassifyColorizer':
sym.colorizer.classificationField = 'Value'
sym.colorizer.breakCount = 7
sym.colorizer.colorRamp = p.listColorRamps('Cyan to Purple')[0]
l.symbology = sym
p.saveACopy(relpath + r'\\SavedOutput.aprx')
The following script modifies the symbology of a raster layer that uses a raster classified colorizer. It sets classificationField, breakCount, and noDataColor. Next, it iterates through each raster class break and modifies the upperBound, label, description, and color properties. The labels for each break are formatted to include the less than or equal symbol and thousands separators. The HSV colors for each raster class break are incremented by even intervals.
# -*- coding: utf-8 -*-
import arcpy
import os
import sys
import locale
relpath = os.path.dirname(sys.argv[0])
p = arcpy.mp.ArcGISProject(relpath + r'\\RasterClassify.aprx')
m = p.listMaps('Map')[0]
l = m.listLayers('Raster1')[0]
sym = l.symbology
sym.colorizer.classificationField = "Value"
sym.colorizer.breakCount = 5
sym.colorizer.noDataColor = {'RGB': [255, 255, 255, 100]}
breakVal = 50
cv = 0
for brk in sym.colorizer.classBreaks:
brk.upperBound = breakVal
brk.label = "\u2264" + str(locale.format("%d", breakVal, grouping=True))
brk.description = "Description " + str(cv)
brk.color = {'HSV' : [cv, cv, cv, 100]}
breakVal +=50
cv += 40
l.symbology = sym
p.saveACopy(relpath + r'\\SavedOutput.aprx')