<?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: Programmatically Set Colors for Unique Values Symbology? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455500#M35802</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;anyone know if we have access to the "colors" used for unique symbology?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://ideas.arcgis.com/ideaView?id=087E00000004REYIA2"&gt;http://ideas.arcgis.com/ideaView?id=087E00000004REYIA2&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;At 10.1 we added minScale and maxScale properties on the Layer Class so you can get and set the scale range of a layer. We also added a symbologyType property to ask the layer what kind of symbology it has defined and the symbology propety to allow you to access and modify some properties of the symbology.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 19 Aug 2013 22:17:57 GMT</pubDate>
    <dc:creator>AmyKlug</dc:creator>
    <dc:date>2013-08-19T22:17:57Z</dc:date>
    <item>
      <title>Programmatically Set Colors for Unique Values Symbology?</title>
      <link>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455496#M35798</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have Python code that iterates through about 100 value fields and makes a single PDF composed of maps from each display.&amp;nbsp; I am using Unique Values Symbology, and I would like to figure out a way to programmatically control the color that is displayed with each value.&amp;nbsp; That is, value A should be red on all the maps, Value B blue, etc.&amp;nbsp; Is there a way to do this with arcpy?&amp;nbsp; Or, if not, what is the quickest way to accomplish this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The existing code I cobbled together using examples on this forum, and so I thought I would pay forward by including the existing code for&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;#This code reads in a list of Species Names from a Table
#then interates through those and for each one sets the
#symbology on the map to a corresponding field and exports
#each page as a part of a single PDF


import arcpy,os

def MakeMap(SpeciesName):
&amp;nbsp;&amp;nbsp;&amp;nbsp; #Takes a Species Name and exports a PDF Map
&amp;nbsp;&amp;nbsp;&amp;nbsp; #The field name is Based on Species Name

&amp;nbsp;&amp;nbsp;&amp;nbsp; print SpeciesName
&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldName="SpeciesData$." + SpeciesName + "__Source"
&amp;nbsp;&amp;nbsp;&amp;nbsp; FieldName=FieldName.replace (" ","_")

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set title on Map
&amp;nbsp;&amp;nbsp;&amp;nbsp; for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "Title"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = SpeciesName

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Set Unique Values Field to FieldName
&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.symbologyType == "UNIQUE_VALUES":
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.symbology.valueField = FieldName
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.symbology.addAllValues()

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Remove Null Value fron display
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sourceList=lyr.symbology.classValues
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sourceList.remove("&amp;lt;Null&amp;gt;")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.symbology.classValues=sourceList
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.symbology.showotherValues = False

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshActiveView()
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.RefreshTOC()

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Position Legend
&amp;nbsp;&amp;nbsp;&amp;nbsp; legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT", "Legend")[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; legend.elementPositionY=.15

&amp;nbsp;&amp;nbsp;&amp;nbsp; #Export to PDF
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.ExportToPDF(mxd, r"C:\temp.pdf")
&amp;nbsp;&amp;nbsp;&amp;nbsp; pdfDoc.appendPages(r"C:\temp.pdf")
&amp;nbsp;&amp;nbsp;&amp;nbsp; return


sourceList = []
speciesList = []
mxd = arcpy.mapping.MapDocument("current")
lyr = arcpy.mapping.ListLayers(mxd, "DistrictMap")[0]

#Fill Species List from Table
fc = "C:\Species List.xlsx\Species_List$"
rows = arcpy.SearchCursor(fc)
for row in rows:
&amp;nbsp;&amp;nbsp;&amp;nbsp; speciesList.append(row.Species)

#Set PDF file name and remove if it already exists
pdfPath = r"C:\FullMapsPDF.pdf"
if os.path.exists(pdfPath):
&amp;nbsp;&amp;nbsp;&amp;nbsp; os.remove(pdfPath)
#Create the PDF file
pdfDoc = arcpy.mapping.PDFDocumentCreate(pdfPath)

#Iterate through Species
for MySpecies in speciesList:
&amp;nbsp;&amp;nbsp;&amp;nbsp; MakeMap(MySpecies)

#Commit changes and delete variable reference
pdfDoc.saveAndClose()
del pdfDoc
del mxd
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 18:31:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455496#M35798</guid>
      <dc:creator>PatrickLivingood</dc:creator>
      <dc:date>2013-08-19T18:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically Set Colors for Unique Values Symbology?</title>
      <link>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455497#M35799</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, if value A and B are the same in all the maps, the easiest way would be to open ArcMap, load your feature class and symbolize as desired.&amp;nbsp; then, right click on the FC and save as layer file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then, you can use UpdateLayer in python to update the symbology using the layer file you created &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/UpdateLayer/00s30000003p000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/UpdateLayer/00s30000003p000000/&lt;/A&gt;&lt;SPAN&gt; .&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the values for A and B can differ, you can set up and create the layer file in python &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Layer/00s300000008000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/Layer/00s300000008000000/&lt;/A&gt;&lt;SPAN&gt; , then use that one to update the layer(s).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 19:32:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455497#M35799</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-08-19T19:32:48Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically Set Colors for Unique Values Symbology?</title>
      <link>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455498#M35800</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Well, if value A and B are the same in all the maps, the easiest way would be to open ArcMap, load your feature class and symbolize as desired.&amp;nbsp; then, right click on the FC and save as layer file.&lt;BR /&gt;&lt;BR /&gt;Then, you can use UpdateLayer in python to update the symbology using the layer file you created &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/UpdateLayer/00s30000003p000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/UpdateLayer/00s30000003p000000/&lt;/A&gt; .&lt;BR /&gt;&lt;BR /&gt;If the values for A and B can differ, you can set up and create the layer file in python &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#/Layer/00s300000008000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#/Layer/00s300000008000000/&lt;/A&gt; , then use that one to update the layer(s).&lt;BR /&gt;&lt;BR /&gt;R_&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you so much for helping, but I am not sure about your answer.&amp;nbsp; Let me explain my problem a little more clearly.&amp;nbsp; My table is a series of counties.&amp;nbsp; For each county there are about 100 fields that list source data for each of 100 species.&amp;nbsp; If no value exists, then the species has not been noted in that county.&amp;nbsp; If the species has been recorded in that county then there is a an academic source such as Adams 1900 or Bruce 1985 or Cohn 1990 listed that is the source of the information about its presence.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The script I posted above iterates through each of the species and shows a unique color map for each so that the presence/absence and the academic source for the information can be understood.&amp;nbsp; What I would like to ensure is that Adams 1900 is always red in all the maps, Bruce 1985 is always blue, etc.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are about 14 sources and they show up on each of the species maps in varying combinations.&amp;nbsp; One map might only have Adams 1900, another might only have Bruce 1985, yet another might have 10 different sources.&amp;nbsp; I would estimate about 30 permutations of sources present exist across my 100 maps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the first example you provide above, that changes the symbology including the DisplayField, which is not really what I want.&amp;nbsp; In the second, that shows some of the Layer properties exposed in arcpy, but I am not sure how to access colors for a Unique_Value map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Help is definitely appreciated!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 20:21:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455498#M35800</guid>
      <dc:creator>PatrickLivingood</dc:creator>
      <dc:date>2013-08-19T20:21:47Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically Set Colors for Unique Values Symbology?</title>
      <link>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455499#M35801</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, that definatly gets more complicated, however, if you are using 10.1, here is one way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Open your arcmap document that has the most permeatations.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;create the symbology you want for the values (if it doesn't exist in that layer/map, you can add value to the list, even if it isn't displayed)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Adams 1900 - red&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Bruce 1985&amp;nbsp; - blue&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; etc...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;now, save that as a layer file.&amp;nbsp; in your map document, legend properties, check the box that says "Only show classes that are visible in the current map extent" and save the mxd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, with python, after you have your data genereated, us the updateSymbology to apply that layer file to the FC.&amp;nbsp; With the "Only show" box checked, you will only see the values/symbology for feature that show in the current layout extent, so, if a particular permeatation doesn't exist in the map, it won't display it on the legend.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Of course, now that I think about it some, ESRI has not given python access to the "only show " legend box, so you would have to manually set that on your layer in all your mxd's.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; Might be able to utilize a template to set this on all mxd's, would have to look into that a little.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see we can change class values, labels, etc., but I don't see any way to assign a color to a feature using python, other than with a .lyr file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If we could, there might be a way to iterate through all of them and append the classes to a list, then get the unique set, create a dictionary from that and apply it to the layer(s) you want.&amp;nbsp; however, not sure how you would control the colors&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;anyone know if we have access to the "colors" used for unique symbology?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;In the first example you provide above, that changes the symbology including the DisplayField, which is not really what I want. In the second, that shows some of the Layer properties exposed in arcpy, but I am not sure how to access colors for a Unique_Value map.&lt;BR /&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;symbology_only - A Boolean that determines whether or not to update only the layer's symbology, or all other properties as well. If set to True, only the layer's symbology will be updated.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 21:17:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455499#M35801</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-08-19T21:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically Set Colors for Unique Values Symbology?</title>
      <link>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455500#M35802</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;anyone know if we have access to the "colors" used for unique symbology?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://ideas.arcgis.com/ideaView?id=087E00000004REYIA2"&gt;http://ideas.arcgis.com/ideaView?id=087E00000004REYIA2&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;At 10.1 we added minScale and maxScale properties on the Layer Class so you can get and set the scale range of a layer. We also added a symbologyType property to ask the layer what kind of symbology it has defined and the symbology propety to allow you to access and modify some properties of the symbology.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 19 Aug 2013 22:17:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455500#M35802</guid>
      <dc:creator>AmyKlug</dc:creator>
      <dc:date>2013-08-19T22:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically Set Colors for Unique Values Symbology?</title>
      <link>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455501#M35803</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;It sounds like arcpy does not currently support the ability to set the Unique Value colors like I need to for this application.&amp;nbsp; I have experimented with the updateSymbology tool and I cannot get the effect I need.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcGIS currently supports a lot of different scripting technologies.&amp;nbsp; Which one would be the recommended one to do this task: iterate through about 100 different variables and for each one produce a unique values map, set its colors correctly, and export all of the maps to a PDF?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 26 Aug 2013 19:56:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/programmatically-set-colors-for-unique-values/m-p/455501#M35803</guid>
      <dc:creator>PatrickLivingood</dc:creator>
      <dc:date>2013-08-26T19:56:08Z</dc:date>
    </item>
  </channel>
</rss>

