<?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: How to access raster classification alias from layer in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-access-raster-classification-alias-from/m-p/1555102#M73135</link>
    <description>&lt;P&gt;You can retrieve this by using the CIM definition properties of the raster layer.&amp;nbsp; More specifically, using the colorizer property.&amp;nbsp; I assumed you are using the Unique Values symbology type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# Access the current ArcGIS Pro project and the specific map and raster layer
project = arcpy.mp.ArcGISProject("CURRENT")
map_obj = project.listMaps("YourMapName")[0]  # Replace "YourMapName" with your map name
raster_layer = map_obj.listLayers("YourRasterLayerName")[0]  # Replace with your raster layer's name

# Get the CIM definition of the raster layer
cim_def = raster_layer.getDefinition('V3')

# Check if the colorizer is of type CIMRasterUniqueValueColorizer
if isinstance(cim_def.colorizer, arcpy.cim.CIMRasterUniqueValueColorizer):
    # Access the Unique Value Colorizer properties
    unique_value_colorizer = cim_def.colorizer
    
    # Iterate through each unique value class in the first group
    for unique_value_class in unique_value_colorizer.groups[0].classes:
        label = unique_value_class.label
        values = unique_value_class.values  # List of values for this unique class
        color = unique_value_class.color  # RGBA color as a CIMColor object
        
        print(f"Label: {label}")
        print(f"Values: {values}")
        print(f"Color: RGBA({color.values[0]}, {color.values[1]}, {color.values[2]}, {color.values[3]})")
        print("----")
else:
    print("The raster layer does not have a CIMRasterUniqueValueColorizer applied.")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Nov 2024 16:07:58 GMT</pubDate>
    <dc:creator>Marshal</dc:creator>
    <dc:date>2024-11-04T16:07:58Z</dc:date>
    <item>
      <title>How to access raster classification alias from layer</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-raster-classification-alias-from/m-p/1522863#M73028</link>
      <description>&lt;P&gt;I'm creating a python toolbox geoprocessing tool that will take a raster map layer as input (USA NLCD Land Cover), do some analysis on it, and generate a report - basically tabulating the acreage of the different land cover types (eg. open water, barren land, mixed forest...) for a given area. In the report I'd like to show the classification labels, but I can only see how to access the actual numeric pixel values (eg. 1,2,3, etc).&amp;nbsp; I assumed I could get this throught the layer's symbology, but I'm not seeing it.&amp;nbsp; How can I use arcpy to find the mapping from numeric classification to the text label, starting from a Layer object?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 13:42:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-raster-classification-alias-from/m-p/1522863#M73028</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2024-08-16T13:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to access raster classification alias from layer</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-raster-classification-alias-from/m-p/1555102#M73135</link>
      <description>&lt;P&gt;You can retrieve this by using the CIM definition properties of the raster layer.&amp;nbsp; More specifically, using the colorizer property.&amp;nbsp; I assumed you are using the Unique Values symbology type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

# Access the current ArcGIS Pro project and the specific map and raster layer
project = arcpy.mp.ArcGISProject("CURRENT")
map_obj = project.listMaps("YourMapName")[0]  # Replace "YourMapName" with your map name
raster_layer = map_obj.listLayers("YourRasterLayerName")[0]  # Replace with your raster layer's name

# Get the CIM definition of the raster layer
cim_def = raster_layer.getDefinition('V3')

# Check if the colorizer is of type CIMRasterUniqueValueColorizer
if isinstance(cim_def.colorizer, arcpy.cim.CIMRasterUniqueValueColorizer):
    # Access the Unique Value Colorizer properties
    unique_value_colorizer = cim_def.colorizer
    
    # Iterate through each unique value class in the first group
    for unique_value_class in unique_value_colorizer.groups[0].classes:
        label = unique_value_class.label
        values = unique_value_class.values  # List of values for this unique class
        color = unique_value_class.color  # RGBA color as a CIMColor object
        
        print(f"Label: {label}")
        print(f"Values: {values}")
        print(f"Color: RGBA({color.values[0]}, {color.values[1]}, {color.values[2]}, {color.values[3]})")
        print("----")
else:
    print("The raster layer does not have a CIMRasterUniqueValueColorizer applied.")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Nov 2024 16:07:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-raster-classification-alias-from/m-p/1555102#M73135</guid>
      <dc:creator>Marshal</dc:creator>
      <dc:date>2024-11-04T16:07:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to access raster classification alias from layer</title>
      <link>https://community.esri.com/t5/python-questions/how-to-access-raster-classification-alias-from/m-p/1555678#M73140</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/389506"&gt;@Marshal&lt;/a&gt;!&lt;/P&gt;</description>
      <pubDate>Wed, 06 Nov 2024 01:07:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-access-raster-classification-alias-from/m-p/1555678#M73140</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2024-11-06T01:07:45Z</dc:date>
    </item>
  </channel>
</rss>

