Hello,
I'm migrating a Ptyhon script for ArcGIS 10.x to ArcGIS Pro 2.9. There is one 10.x code that I can't find equivalent to Pro.
where layer is a raster. What I want to do is not to give a color to raster cells whose value is 0.
If I open an ArcGIS Pro project, I can do this by going to the Symbology pane and Advanced symbology options. Then, enter "0" to "Data exclusion" box.
Does anyone know how to do this in a Python script for ArcGIS Pro 2.9 (or 3.x; I have both versions)?
Thanks,
This may be set in the noDataColor of the colorizer. Not sure what type symbology type (stretch, classify, unique, etc.,.) you are using so find the one and adapt the example.
sym.noDataColor = {'RGB': [0, 0, 0, 0]}
import arcpy
p = arcpy.mp.ArcGISProject(r'CURRENT')
m = p.listMaps('Map')[0]
l = m.listLayers('rastermaster')[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]
sym.noDataColor = {'RGB': [0, 0, 0, 0]}
l.symbology = sym