<?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: UniqueValueRenderer not coloring polygons in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281328#M67478</link>
    <description>&lt;P&gt;Thanks, &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/662373"&gt;@Mahdi_Ch&lt;/a&gt;: it runs without applying! And it is the current project. I'll add in the actual project and see how it does, but I imagine that won't change anything.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2023 15:53:08 GMT</pubDate>
    <dc:creator>nsidaniel</dc:creator>
    <dc:date>2023-04-21T15:53:08Z</dc:date>
    <item>
      <title>UniqueValueRenderer not coloring polygons</title>
      <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281311#M67475</link>
      <description>&lt;P&gt;I'm trying to do what seems really simple via arcpy: color a layer's 4 classes! I cannot see where my code is wrong. I based it on esri: &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/uniquevaluerenderer-class.htm" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/uniquevaluerenderer-class.htm&lt;/A&gt;. Any help would be appreciated!&lt;/P&gt;&lt;P&gt;Maybe my issue is that I'm ignoring that the attribute table was generated via domains' drop-down lists? Maybe I need to bite the bullet and use CIM access.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Color and setup features 2
import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])
p = arcpy.mp.ArcGISProject(os.path.join(relpath+"CURRENT"))
m = p.listMaps('Map')[0]
l = m.listLayers(TWP + "_RIGHTS")[0]
sym = l.symbology
        
sym.updateRenderer('UniqueValueRenderer')
sym.renderer.fields = ['RightsType']
for grp in sym.renderer.groups:
    for itm in grp.items:
        
        value = itm.values[0]
        if value == "Choose":
            itm.renderer.symbol.color = {"RGB": [0, 0, 0, 50]}      
            itm.renderer.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.renderer.symbol.outlineWidth = 0.75  
            itm.renderer.symbol.size = 1
            itm.renderer.label = str(value)
        
        if value == "Easement":
            itm.renderer.symbol.color = {"RGB": [0, 112, 255, 50]}      
            itm.renderer.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.renderer.symbol.outlineWidth = 0.75  
            itm.renderer.symbol.size = 1
            itm.renderer.symbol.label = str(value)
                                              
        if value == "Fee":
            itm.renderer.symbol.color = {"RGB": [56, 168, 0, 50]}
            itm.renderer.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.renderer.symbol.outlineWidth = 0.75
            itm.renderer.symbol.size = 1
            itm.renderer.symbol.label = str(value)
                                                   
        if value == "License":
            itm.renderer.symbol.color = {"RGB": [0, 0, 255, 50]}
            itm.renderer.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.renderer.symbol.outlineWidth = 0.75
            itm.renderer.symbol.size = 1
            itm.renderer.symbol.label = str(value)
                    
l.symbology = sym
p.saveACopy(os.path.join(relpath+"CURRENT"))     
        
print("Completed"+" "+time.strftime("%x" +" "+ "(%a)" +" "+ "at"+" "+"%I:%M"))&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 21 Apr 2023 15:19:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281311#M67475</guid>
      <dc:creator>nsidaniel</dc:creator>
      <dc:date>2023-04-21T15:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: UniqueValueRenderer not coloring polygons</title>
      <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281318#M67476</link>
      <description>&lt;P&gt;I guess it help better if you include the error.(or maybe no error just runs without applying?) But the first thing that I noticed is this line:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;p = arcpy.mp.ArcGISProject(os.path.join(relpath+"CURRENT"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe you cannot combine the path and "CURRENT", if you are not using the current project, you can put the project name there though. sth like:&amp;nbsp; relpath+"\\projectname.aprx"&lt;/P&gt;&lt;P&gt;Although, it might work out of luck if relpath is empty.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 15:40:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281318#M67476</guid>
      <dc:creator>Mahdi_Ch</dc:creator>
      <dc:date>2023-04-21T15:40:43Z</dc:date>
    </item>
    <item>
      <title>Re: UniqueValueRenderer not coloring polygons</title>
      <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281328#M67478</link>
      <description>&lt;P&gt;Thanks, &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/662373"&gt;@Mahdi_Ch&lt;/a&gt;: it runs without applying! And it is the current project. I'll add in the actual project and see how it does, but I imagine that won't change anything.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 15:53:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281328#M67478</guid>
      <dc:creator>nsidaniel</dc:creator>
      <dc:date>2023-04-21T15:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: UniqueValueRenderer not coloring polygons</title>
      <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281343#M67479</link>
      <description>&lt;P&gt;Yeah, if it runs without errors that shouldn't change anything! That means if you check the value for relpath it should be an empty string so you can simply delete that to be like ArcGISProject("CURRENT").&lt;/P&gt;&lt;P&gt;Something else that I noticed is TWP is not defined in your code here, I assume that shouldn't be the case in the actual code that you run.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you tried putting some print statements for value to see if it is among those values you are checking against? ("Choose",&amp;nbsp; "Easement",...) maybe it is not what you think and never falls into any of those ifs?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 16:07:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281343#M67479</guid>
      <dc:creator>Mahdi_Ch</dc:creator>
      <dc:date>2023-04-21T16:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: UniqueValueRenderer not coloring polygons</title>
      <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281373#M67480</link>
      <description>&lt;P&gt;If I align print(value) with each "if" statement, it prints the below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os, sys
p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps('Map')[0]
l = m.listLayers(TWP + "_RIGHTS")[0]
sym = l.symbology
        
sym.updateRenderer('UniqueValueRenderer')
sym.renderer.fields = ['RightsType']
for grp in sym.renderer.groups:
    for itm in grp.items:
       
        value = itm.values[0]
        if value == "Choose":
            itm.renderer.symbol.color = {"RGB": [0, 0, 0, 50]}      
            itm.renderer.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.renderer.symbol.outlineWidth = 0.75  
            itm.renderer.symbol.size = 1
            itm.renderer.label = str(value)
        print(value)
        
        if value == "Easement":
            itm.renderer.symbol.color = {"RGB": [0, 112, 255, 50]}      
            itm.renderer.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.renderer.symbol.outlineWidth = 0.75  
            itm.renderer.symbol.size = 1
            itm.renderer.symbol.label = str(value)
        print(value)
                                              
        if value == "Fee":
            itm.renderer.symbol.color = {"RGB": [56, 168, 0, 50]}
            itm.renderer.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.renderer.symbol.outlineWidth = 0.75
            itm.renderer.symbol.size = 1
            itm.renderer.symbol.label = str(value)
        print(value)
                                                   
        if value == "License":
            itm.renderer.symbol.color = {"RGB": [0, 0, 255, 50]}
            itm.renderer.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.renderer.symbol.outlineWidth = 0.75
            itm.renderer.symbol.size = 1
            itm.renderer.symbol.label = str(value)
        print(value)
                    
l.symbology = sym
p.saveACopy("CURRENT")      
print("Completed"+" "+time.strftime("%x" +" "+ "(%a)" +" "+ "at"+" "+"%I:%M"))

['0']
['0']
['0']
['0']
['1']
['1']
['1']
['1']
['2']
['2']
['2']
['2']
['3']
['3']
['3']
['3']
Completed 4/21/2023 (Fri) at 12:34&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I align print(value) with each itm.renderer.symbol statement it prints nothing. Leads me to believe that "value" stores nothing (value has no value)!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;        if value == "License":
            itm.renderer.symbol.color = {"RGB": [0, 0, 255, 50]}
            itm.renderer.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.renderer.symbol.outlineWidth = 0.75
            itm.renderer.symbol.size = 1
            itm.renderer.symbol.label = str(value)
            print(value)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 18:11:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281373#M67480</guid>
      <dc:creator>nsidaniel</dc:creator>
      <dc:date>2023-04-21T18:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: UniqueValueRenderer not coloring polygons</title>
      <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281423#M67481</link>
      <description>&lt;P&gt;I solved it by adding if itm.label == . Thanks for your help &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/662373"&gt;@Mahdi_Ch&lt;/a&gt;! You guided me in the right direction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, os, sys

p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps('Map')[0]
l = m.listLayers(TWP + "_RIGHTS")[0]
sym = l.symbology
        
sym.updateRenderer('UniqueValueRenderer')
sym.renderer.fields = ['RightsType']
for grp in sym.renderer.groups:
    for itm in grp.items:

        if itm.label == "Choose":
            label = "Choose"
            itm.symbol.color = {"RGB": [0, 0, 0, 50]}      
            itm.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.symbol.outlineWidth = 0.75
            itm.label = str(label)
            print(label)

        if itm.label == "Easement":
            label = "Easement"
            itm.values[0][0]
            itm.symbol.color = {"RGB": [0, 112, 255, 50]}      
            itm.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.symbol.outlineWidth = 0.75  
            itm.label = str(label)
            print(label)
                                              
        if itm.label == "Fee":
            label = "Fee"
            itm.symbol.color = {"RGB": [56, 168, 0, 50]}
            itm.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.symbol.outlineWidth = 0.75
            itm.label = str(label)
            print(label)
                                                   
        if itm.label == "License":
            label = "License"
            itm.symbol.color = {"RGB": [255, 0, 0, 50]}
            itm.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.symbol.outlineWidth = 0.75
            itm.label = str(label)
            print(label)

        l.symbology = sym
aprx.save()     
print("Completed"+" "+time.strftime("%x" +" "+ "(%a)" +" "+ "at"+" "+"%I:%M"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 18:40:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281423#M67481</guid>
      <dc:creator>nsidaniel</dc:creator>
      <dc:date>2023-04-21T18:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: UniqueValueRenderer not coloring polygons</title>
      <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281426#M67482</link>
      <description>&lt;P&gt;value is already a list of list, to get the actual value you should change the line to the following:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;value = itm.values[0][0]
# or alternatively, you can get it from label:
value = itm.label&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;The issue is you are looking for the content of "RightsType" field/column. And apparently that is not what you are looking for (you want "Choose", "Easement",... but the actual values there are "0", "1", "2",...&lt;/P&gt;&lt;P&gt;Looking at the first if statement, since the value ['0'] is not equal&amp;nbsp;to "Choose" it never enters the if statement to do the rest, and jumps to the next one, and the same logic applies for other if statements and basically nothing gets changed (formatting-wise).&lt;/P&gt;&lt;P&gt;Another general tip is since you set the value at line 12 and it never changes, you don't need to repeat the &lt;EM&gt;print(value)&lt;/EM&gt; after each if statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 18:53:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1281426#M67482</guid>
      <dc:creator>Mahdi_Ch</dc:creator>
      <dc:date>2023-04-21T18:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: UniqueValueRenderer not coloring polygons</title>
      <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1282794#M67514</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/662373"&gt;@Mahdi_Ch&lt;/a&gt;,&amp;nbsp;after feeling it was over, the code correctly colors everything ... but doesn't actually write anything to the map! (I took your suggestions to clean things up, thank you!!)&lt;/P&gt;&lt;P&gt;Any ideas why it isn't actually writing to the map? I tried refreshing the map of course, but that didn't do anything. The attribute table definitely contains information.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy, sys
print(TWP)

aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Map")[0]
l = m.listLayers(TWP + "_RIGHTS")[0]
sym = l.symbology

sym.updateRenderer('UniqueValueRenderer')
sym.renderer.fields = ['RightsType']

for grp in sym.renderer.groups:
    for itm in grp.items:

        if itm.label == "Choose":
            label = itm.label
            itm.symbol.color = {"RGB": [0, 0, 0, 50]}      
            itm.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.symbol.outlineWidth = 0.75
            itm.label = str(label)

        if itm.label == "Easement":
            label = itm.label
            itm.symbol.color = {"RGB": [0, 112, 255, 50]}      
            itm.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.symbol.outlineWidth = 0.75  
            itm.label = str(label)

        if itm.label == "Fee":
            label = itm.label
            itm.symbol.color = {"RGB": [56, 168, 0, 50]}
            itm.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.symbol.outlineWidth = 0.75
            itm.label = str(label)

        if itm.label == "License":
            label = itm.label
            itm.symbol.color = {"RGB": [255, 0, 0, 50]}
            itm.symbol.outlineColor = {"RGB": [255, 255, 255, 100]}
            itm.symbol.outlineWidth = 0.75
            itm.label = str(label)
        print(label)
            
        l.symbology = sym
aprx.save() 
print("Completed"+" "+time.strftime("%x" +" "+ "(%a)" +" "+ "at"+" "+"%I:%M"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 13:51:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1282794#M67514</guid>
      <dc:creator>nsidaniel</dc:creator>
      <dc:date>2023-04-26T13:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: UniqueValueRenderer not coloring polygons</title>
      <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1282969#M67525</link>
      <description>&lt;P&gt;The TWP + "_RIGHTS" layer use domains, I'm thinking now that's the source of the problem&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 17:59:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1282969#M67525</guid>
      <dc:creator>nsidaniel</dc:creator>
      <dc:date>2023-04-26T17:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: UniqueValueRenderer not coloring polygons</title>
      <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1283040#M67526</link>
      <description>&lt;P&gt;Huh. It appears that the actual information is stuck in "all other values".&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nsidaniel_0-1682540693601.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69212i1D84AE9D191A4FD9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="nsidaniel_0-1682540693601.png" alt="nsidaniel_0-1682540693601.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Apr 2023 20:26:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uniquevaluerenderer-not-coloring-polygons/m-p/1283040#M67526</guid>
      <dc:creator>nsidaniel</dc:creator>
      <dc:date>2023-04-26T20:26:05Z</dc:date>
    </item>
  </channel>
</rss>

