<?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: arcpy update raster layer symbology using RasterClassifyColorizer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-update-raster-layer-symbology-using/m-p/1580832#M73683</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I used exactly the same code in the pro3.4 version and the legend is not the same. The label automaton remains. Is this happening to anyone else?&lt;/P&gt;</description>
    <pubDate>Fri, 31 Jan 2025 14:49:52 GMT</pubDate>
    <dc:creator>ErzsikeTerezsi</dc:creator>
    <dc:date>2025-01-31T14:49:52Z</dc:date>
    <item>
      <title>arcpy update raster layer symbology using RasterClassifyColorizer</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-raster-layer-symbology-using/m-p/1284238#M67550</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I am trying to add a raster layer to a map in Pro (3.1) and then update the renderer to be&amp;nbsp;RasterClassifyColorizer.&amp;nbsp; Once that is done, I then try to add a number breaks, update the upper bounds values of the breaks, labels and colors for the breaks.&amp;nbsp; Once done the legend for the raster looks right (right number of classes, right labels and colors) but the raster values seem to be allocated to the wrong classes.&lt;/P&gt;&lt;P&gt;The data is a floating point raster stored in a TIFF representing wind speed in meters per second.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am doing this via a cell in a Notebook.&lt;/P&gt;&lt;P&gt;The image below shows the rater added manually from the catalog, with a data range of 6.1 to 10.1&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MicrosoftTeams-image.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69548i8A4476A69F590C4C/image-size/large?v=v2&amp;amp;px=999" role="button" title="MicrosoftTeams-image.png" alt="MicrosoftTeams-image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The following image shows the same raster added via the code, showing a large area under 2 meters a second wind speed, which shouldn't be possible:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MicrosoftTeams-image (1).png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69549iFA727F4E8180814D/image-size/large?v=v2&amp;amp;px=999" role="button" title="MicrosoftTeams-image (1).png" alt="MicrosoftTeams-image (1).png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Included is the code from the cell.&amp;nbsp; The pathway to the TIFF is stored in the variable "rdSaWSatX"&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Access the Project and Map objects to add the layers to
p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps("Map")[0]

# Study Area (AOI) Wind Speed raster and
# 1. Give it a "layer name" for display in the map
# 2. Make a raster layer with name
# 3. Access the layer object
# 4. Access the symbology object
# 5. Modify the symbology breaks, lables, and colors
# 6. Apply the modified symbology

# Layer name text
lyrnSaWSatX = f"Study area Wind Speed at {fltHubHeight}m"
# Create Raster Layer
lyrSaWSatX = arcpy.MakeRasterLayer_management(rdSaWSatX, lyrnSaWSatX)
# Add raster layer to the map
m.addLayer(lyrSaWSatX[0], "TOP")
# Access the layer object in the map
lmSaWSatX = m.listLayers(lyrnSaWSatX)[0]
# Access the symbology object
symSaWSatX = lmSaWSatX.symbology
# Update the colorizer to be a classifed one
symSaWSatX.updateColorizer('RasterClassifyColorizer')
symSaWSatX.colorizer.classificationField = "Value"
# Create lists for break values, labels, and colors
lsWSBreakValues = [2,4,6,8,10,12,14,16,18,20,26]
lsWSBreakLabels = []
for ws in lsWSBreakValues:
    label = "&amp;lt;= " + str(ws) + "m/s"
    lsWSBreakLabels.append(label)
    del label
lsWSBreakColours = [[190,232,255,100],
                  [175,245,177,100],
                  [171,253,102,100],
                    [212,243,38,100],
                    [241,222,0,100],
                    [251,185,0,100],
                    [255,113,0,100],
                    [255,19,0,100],
                    [255,0,88,100],
                    [255,0,197,100],
                    [168,0,132,100]]

# Create breaks in map layer
symSaWSatX.colorizer.breakCount = len(lsWSBreakValues)
symCounter = 0
# for each break get values from lists to allocate break value, label and color
for brk in symSaWSatX.colorizer.classBreaks:
    brk.upperBound = lsWSBreakValues[symCounter]
    brk.label = lsWSBreakLabels[symCounter]
    brk.color = {'RGB' : lsWSBreakColours[symCounter]}
    symCounter += 1
# Apply the updated symbology to the map layer
lmSaWSatX.symbology = symSaWSatX&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;and I have arcpy, os and math&amp;nbsp; packages imported.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated,&lt;/P&gt;&lt;P&gt;Nick&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 06:45:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-raster-layer-symbology-using/m-p/1284238#M67550</guid>
      <dc:creator>NickAtEsriAU</dc:creator>
      <dc:date>2023-05-01T06:45:27Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy update raster layer symbology using RasterClassifyColorizer</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-raster-layer-symbology-using/m-p/1284348#M67556</link>
      <description>&lt;P&gt;Doing a test on a raster, it seems to work ok for me.&amp;nbsp; One thing I'd suggest is to be more explicit with the upper boundary, label, and color by using a dictionary. This method prevents a list index being off and reduces some looping.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;breaks = {0: {'upper': 2, 'color': [190, 232, 255, 100]},
          1: {'upper': 4, 'color': [175, 245, 177, 100]},
          2: {'upper': 6, 'color': [171, 253, 102, 100]},
          3: {'upper': 8, 'color': [212, 243, 38, 100]},
          4: {'upper': 10, 'color': [241, 222, 0, 100]},
          5: {'upper': 12, 'color': [251, 185, 0, 100]},
          6: {'upper': 14, 'color': [255, 113, 0, 100]},
          7: {'upper': 16, 'color': [255, 19, 0, 100]},
          8: {'upper': 18, 'color': [255, 0, 88, 100]},
          9: {'upper': 20, 'color': [255, 0, 197, 100]},
          10: {'upper': 26, 'color': [168, 0, 132, 100]}
          }

# Create breaks in map layer
symSaWSatX.colorizer.breakCount = len(breaks)

# for each break get values from lists to allocate break value, label and color
for i, brk in enumerate(symSaWSatX.colorizer.classBreaks):
    brk.upperBound = breaks[i]['upper']
    brk.label = label = "&amp;lt;= " + str(breaks[i]['upper']) + "m/s"
    brk.color = {'RGB': breaks[i]['color']}

# Apply the updated symbology to the map layer
lmSaWSatX.symbology = symSaWSatX

p.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2023 14:55:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-raster-layer-symbology-using/m-p/1284348#M67556</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2023-05-01T14:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy update raster layer symbology using RasterClassifyColorizer</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-raster-layer-symbology-using/m-p/1306854#M68119</link>
      <description>&lt;P&gt;Many thanks Jeff.&amp;nbsp; I applied your structure and had success.&amp;nbsp; interestingly, I am using your structure&amp;nbsp; for another script but for a&amp;nbsp;GraduatedColorsRenderer on a polygon layer and I am still having issues where some classes aren't shown.&amp;nbsp; I am going to this another post though as it is off topic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many Thanks,&lt;/P&gt;&lt;P&gt;Nick&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 03:19:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-raster-layer-symbology-using/m-p/1306854#M68119</guid>
      <dc:creator>NickAtEsriAU</dc:creator>
      <dc:date>2023-07-10T03:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy update raster layer symbology using RasterClassifyColorizer</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-raster-layer-symbology-using/m-p/1580832#M73683</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I used exactly the same code in the pro3.4 version and the legend is not the same. The label automaton remains. Is this happening to anyone else?&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2025 14:49:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-raster-layer-symbology-using/m-p/1580832#M73683</guid>
      <dc:creator>ErzsikeTerezsi</dc:creator>
      <dc:date>2025-01-31T14:49:52Z</dc:date>
    </item>
    <item>
      <title>Re: arcpy update raster layer symbology using RasterClassifyColorizer</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-update-raster-layer-symbology-using/m-p/1597157#M73932</link>
      <description>&lt;P&gt;I had the same issue. I added a label to the dictionary and in preliminary testing I was able to print the labels to the python consol, but nothing changed in the legend/TOC.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2025 16:09:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-update-raster-layer-symbology-using/m-p/1597157#M73932</guid>
      <dc:creator>SarahORourke</dc:creator>
      <dc:date>2025-03-19T16:09:27Z</dc:date>
    </item>
  </channel>
</rss>

