<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Troubles setting Consistent Symbology in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/troubles-setting-consistent-symbology/m-p/1595867#M73921</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/16421"&gt;@DougBrowning&lt;/a&gt;&amp;nbsp;I've taken a look at this and I'm also bringing this to the attention of the raster team.&amp;nbsp; A few things.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) With Python, I'm able to standardize symbology across multiple rasters BUT only if I set the lowerBound of the raster.&amp;nbsp; This property was made available on GraduatedColorsRenderer, GraduatedSymbolsRenderer and RasterClassifyColorizer at Pro 3.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;#Standardize multiple RasterClassifyColorizer elevation datasets&lt;/P&gt;&lt;P&gt;p = arcpy.mp.ArcGISProject('current')&lt;/P&gt;&lt;P&gt;m = p.listMaps('Yosemite Elevation')[0]&lt;/P&gt;&lt;P&gt;for l in m.listLayers('*dem'):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if l.isRasterLayer:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lBound = 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uBound = 300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sym = l.symbology&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sym.colorizer.colorRamp = p.listColorRamps('Elevation #1')[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sym.colorizer.breakCount = 10 #final range: 0-3000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;sym.colorizer.lowerBound = 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for brk in sym.colorizer.classBreaks:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; brk.upperBound = uBound&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; brk.label = f"{lBound} - {uBound} meters"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lBound += 300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uBound += 300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.symbology = sym&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;2) It appears I can't do this in the UI.&amp;nbsp; The UI does not let me create ranges below the minimum value.&amp;nbsp; It lets me create ranges for upper values that don't exist with no issue.&amp;nbsp; If I try to set the lower bound via the Histogram tab but changing it to Zero has no effect on the colorizer (Unlike the GraduatedColors/symbols renderers). Even if I successfully set symbology via arcpy.mp like above, when I view the symbology pane, I get a warning.&lt;/P&gt;&lt;P&gt;3) There is a bug you may run into concerning labels.&amp;nbsp; During Pro 3.4 development, auto apply labels behavior was added to the UI behavior and it causes arcpy.mp class label modifications to get reset.&amp;nbsp; We have a fix for this at Pro 3.5 and hope to port it to a patch for 3.4.&amp;nbsp; The bug is&amp;nbsp;BUG-000174482.&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Jeff - arcpy.mp and Layout (SDK) teams&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Mar 2025 03:38:48 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2025-03-16T03:38:48Z</dc:date>
    <item>
      <title>Troubles setting Consistent Symbology</title>
      <link>https://community.esri.com/t5/python-questions/troubles-setting-consistent-symbology/m-p/1582467#M73710</link>
      <description>&lt;P&gt;I thought I had this figured out but it came back again.&lt;/P&gt;&lt;P&gt;In Pro if you try to set symbology outside the layer values it gets mad.&amp;nbsp; This is actually highly annoying because then we can never set consistent colors.&lt;/P&gt;&lt;P&gt;In code it seems to let me do it unless the scale is really small.&amp;nbsp; Like -0.0003 to 0.0003 the classify values below with fail.&amp;nbsp; Again highly annoying.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So here I try to set 10 breaks.&amp;nbsp; If that fails I default to generic symbols.&amp;nbsp; Again I really do not want to do that as then the user cannot compare anything.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;        sym = rasterLayer.symbology
        sym.updateColorizer('RasterClassifyColorizer')
        # was Condition Number
        sym.colorizer.colorRamp = project.listColorRamps('Prediction')[0]
        sym.colorizer.classificationField = "Value"
        sym.colorizer.breakCount = 10
        #sym.colorizer.noDataColor = {'RGB': [255, 255, 255, 100]}

        # manual breaks
        # this will fail on small time periods
        if len(sym.colorizer.classBreaks) == 10:
            sym.colorizer.classBreaks[0].upperBound = -100
            sym.colorizer.classBreaks[0].label = "Over -40%"
            sym.colorizer.classBreaks[1].upperBound = -40
            sym.colorizer.classBreaks[1].label = "-30% to -40%"
            sym.colorizer.classBreaks[2].upperBound = -30
            sym.colorizer.classBreaks[2].label = "-20% to -30%"
            sym.colorizer.classBreaks[3].upperBound = -20
            sym.colorizer.classBreaks[3].label = "-10% to -20%"
            sym.colorizer.classBreaks[4].upperBound = -10
            sym.colorizer.classBreaks[4].label = "0% to -10%"
            sym.colorizer.classBreaks[5].upperBound = 10
            sym.colorizer.classBreaks[5].label = "0% to 10%"
            sym.colorizer.classBreaks[6].upperBound = 20
            sym.colorizer.classBreaks[6].label = "10% to 20%"
            sym.colorizer.classBreaks[7].upperBound = 30
            sym.colorizer.classBreaks[7].label = "20% to 30%"
            sym.colorizer.classBreaks[8].upperBound = 40
            sym.colorizer.classBreaks[8].label = "30% to 40%"
            sym.colorizer.classBreaks[9].upperBound = 100
            sym.colorizer.classBreaks[9].label = "Over 40%"
        else:
            arcpy.AddMessage("Warning Trend Rasters may not work with short time frames. Trying reduced symbols.")
            sym.updateColorizer('RasterStretchColorizer')
            sym.colorizer.colorRamp = project.listColorRamps('Condition Number')[0]
            sym.colorizer.stretchType = "StandardDeviation"
        rasterLayer.name = "Total Change"
        rasterLayer.symbology = sym&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But today we had a case where the value range was -7 to 8 and the breaks did set to -40 to 40 like I want BUT the entire map all draws at a single color.&amp;nbsp; So my check to look for not 10 breaks fix fails.&amp;nbsp; If I ask it how many breaks it does say 10.&amp;nbsp; And my bounds are correct.&amp;nbsp; Worse it sets the color to the first blue - so now the user thinks its all in the &amp;gt;-40% category.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DougBrowning_0-1738793246629.png" style="width: 459px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124712iB3C65EEE111D73FD/image-dimensions/459x468?v=v2" width="459" height="468" role="button" title="DougBrowning_0-1738793246629.png" alt="DougBrowning_0-1738793246629.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas on how to fix this?&amp;nbsp; I am pretty confused why symbology will not let me set anything I want.&amp;nbsp; We cannot have all the maps using a different color scale.&amp;nbsp; That is weird.&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 22:10:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/troubles-setting-consistent-symbology/m-p/1582467#M73710</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2025-02-05T22:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Troubles setting Consistent Symbology</title>
      <link>https://community.esri.com/t5/python-questions/troubles-setting-consistent-symbology/m-p/1586102#M73754</link>
      <description>&lt;P&gt;&lt;STRIKE&gt;Couldn't quite get all the way there, but I was able to consistently get the label classes to generate with this:&lt;/STRIKE&gt;&lt;/P&gt;&lt;P&gt;I forgot to re-apply raster_sym to raster_layer.symbology. This actually works now&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: The docstring for build_breaks is outdated, originally I was skipping 0 like in your example, but it seems to add the 0 break to the end if you do that, so now you can pass a 'zero_break' argument to change the label for 0 (default is 'No Change')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
from arcpy._mp import ArcGISProject, Layer, ColorRamp, Symbology
from arcpy._symbology import RasterClassifyColorizer

from arcpy.cim import (
    CIMRasterLayer, 
    CIMRasterClassifyColorizer, 
    CIMRasterClassBreak, 
    ClassificationMethod, 
)

def build_breaks(min_break: int, max_break: int, total_breaks: int, 
                 units: str = '%', 
                 zero_break: str = 'No Change') -&amp;gt; list[tuple[int, str]]:
    """Build breaks and labels for the colorizer
    
    Args:
        min_break (int): The minimum break value (&amp;gt; -100)
        max_break (int): The maximum break value (&amp;lt; 100)
        total_breaks (int): The total number of breaks
        skip_zero (bool, optional): Skip the zero break if it is in the step. Defaults to True.
    """
    # Raise some errors if the input is invalid
    if min_break &amp;gt; max_break:
        raise ValueError("min_break must be less than max_break")
    
    if min_break &amp;lt;= -100:
        raise ValueError("min_break must be greater than -100")

    if max_break &amp;gt;= 100:
        raise ValueError("max_break must be less than 100")
    
    # Calculate the step (total_breaks has the 2 extremes removed)
    step = int((max_break - min_break) // (total_breaks-2))
    breaks = []
    
    # Add minimum extreme
    breaks.append((-100, f"Under {min_break}{units}"))
    
    # Build the breaks
    for upper_bound in range(min_break, max_break, step):
        if upper_bound == 0:
            breaks.append((upper_bound, zero_break))
            continue
        breaks.append((upper_bound, f"{upper_bound+step}{units} to {upper_bound}{units}"))
        
    # Add maximum extreme
    breaks.append((100, f"Over {max_break}{units}"))
    
    return breaks


def main():
    project: ArcGISProject = ArcGISProject(r"&amp;lt;path_to_aprx&amp;gt;")
    raster_layer: Layer = project.listMaps()[0].listLayers('&amp;lt;layer_name&amp;gt;')[0]
    
    layer_cim: CIMRasterLayer = raster_layer.getDefinition('V3')
    
    # Build the class breaks
    class_breaks = [CIMRasterClassBreak() for _ in range(10)]
    for (val, label), class_break in zip(build_breaks(-40, 40, 10), class_breaks):
        class_break: CIMRasterClassBreak = class_break
        class_break.label = label
        class_break.upperBound = val
    
    # Build the colorizer
    colorizer = CIMRasterClassifyColorizer()
    colorizer.classificationMethod = ClassificationMethod.Manual
    colorizer.classBreaks = class_breaks
    colorizer.field = "Value"
    
    layer_cim.colorizer.__dict__.update(colorizer.__dict__)
    raster_layer.setDefinition(layer_cim)
    
    raster_sym: Symbology = raster_layer.symbology
    sym_colorizer: RasterClassifyColorizer = raster_sym.colorizer
    color_ramp: ColorRamp = project.listColorRamps('Prediction')[0]
    sym_colorizer.colorRamp = color_ramp
    
    raster_layer.symbology = raster_sym
    
    # Save the project
    project.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2025 23:06:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/troubles-setting-consistent-symbology/m-p/1586102#M73754</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2025-02-17T23:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Troubles setting Consistent Symbology</title>
      <link>https://community.esri.com/t5/python-questions/troubles-setting-consistent-symbology/m-p/1591243#M73852</link>
      <description>&lt;P&gt;Sorry but I do not get your post.&amp;nbsp; I need the breaks to be exact not based on the data range at all.&amp;nbsp; All rasters need to be exactly the same symbology.&lt;/P&gt;&lt;P&gt;This is getting a lot of attention at the office and I am still stuck.&amp;nbsp; For now I test to see if the range is less than 20 and I set it to a generic scale.&amp;nbsp; Not sure why it ignores it or how to tell it did ignore it.&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;</description>
      <pubDate>Mon, 03 Mar 2025 16:05:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/troubles-setting-consistent-symbology/m-p/1591243#M73852</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2025-03-03T16:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Troubles setting Consistent Symbology</title>
      <link>https://community.esri.com/t5/python-questions/troubles-setting-consistent-symbology/m-p/1592395#M73869</link>
      <description>&lt;P&gt;I added a check for small ranges but now that is also failing.&lt;/P&gt;&lt;P&gt;arcpy.management.GetRasterProperties(rasterLayer, "MAXIMUM")&amp;nbsp; will fail if the range is really small but works just fine if the range is larger.&lt;/P&gt;&lt;P&gt;Something is up here.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 18:34:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/troubles-setting-consistent-symbology/m-p/1592395#M73869</guid>
      <dc:creator>DougBrowning</dc:creator>
      <dc:date>2025-03-05T18:34:45Z</dc:date>
    </item>
    <item>
      <title>Re: Troubles setting Consistent Symbology</title>
      <link>https://community.esri.com/t5/python-questions/troubles-setting-consistent-symbology/m-p/1595867#M73921</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/16421"&gt;@DougBrowning&lt;/a&gt;&amp;nbsp;I've taken a look at this and I'm also bringing this to the attention of the raster team.&amp;nbsp; A few things.&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) With Python, I'm able to standardize symbology across multiple rasters BUT only if I set the lowerBound of the raster.&amp;nbsp; This property was made available on GraduatedColorsRenderer, GraduatedSymbolsRenderer and RasterClassifyColorizer at Pro 3.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;#Standardize multiple RasterClassifyColorizer elevation datasets&lt;/P&gt;&lt;P&gt;p = arcpy.mp.ArcGISProject('current')&lt;/P&gt;&lt;P&gt;m = p.listMaps('Yosemite Elevation')[0]&lt;/P&gt;&lt;P&gt;for l in m.listLayers('*dem'):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if l.isRasterLayer:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lBound = 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uBound = 300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sym = l.symbology&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sym.colorizer.colorRamp = p.listColorRamps('Elevation #1')[0]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sym.colorizer.breakCount = 10 #final range: 0-3000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;sym.colorizer.lowerBound = 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for brk in sym.colorizer.classBreaks:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; brk.upperBound = uBound&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; brk.label = f"{lBound} - {uBound} meters"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lBound += 300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uBound += 300&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.symbology = sym&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;2) It appears I can't do this in the UI.&amp;nbsp; The UI does not let me create ranges below the minimum value.&amp;nbsp; It lets me create ranges for upper values that don't exist with no issue.&amp;nbsp; If I try to set the lower bound via the Histogram tab but changing it to Zero has no effect on the colorizer (Unlike the GraduatedColors/symbols renderers). Even if I successfully set symbology via arcpy.mp like above, when I view the symbology pane, I get a warning.&lt;/P&gt;&lt;P&gt;3) There is a bug you may run into concerning labels.&amp;nbsp; During Pro 3.4 development, auto apply labels behavior was added to the UI behavior and it causes arcpy.mp class label modifications to get reset.&amp;nbsp; We have a fix for this at Pro 3.5 and hope to port it to a patch for 3.4.&amp;nbsp; The bug is&amp;nbsp;BUG-000174482.&lt;/P&gt;&lt;P&gt;I hope this helps,&lt;/P&gt;&lt;P&gt;Jeff - arcpy.mp and Layout (SDK) teams&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Mar 2025 03:38:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/troubles-setting-consistent-symbology/m-p/1595867#M73921</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2025-03-16T03:38:48Z</dc:date>
    </item>
  </channel>
</rss>

