<?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 Basic ?: Script to apply color map not working, need help in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233896#M18139</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I lifted some script text out of the help documentation, but nothing happens when I run it in the python window.&amp;nbsp; It appears that the list of rasters returns empty, as the script starts and then finishes in less than one second. I'm new to python, so am not even sure where to begin troubleshooting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(See script posted in third reply, below)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Jun 2011 14:29:29 GMT</pubDate>
    <dc:creator>MarkEllis</dc:creator>
    <dc:date>2011-06-13T14:29:29Z</dc:date>
    <item>
      <title>Basic ?: Script to apply color map not working, need help</title>
      <link>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233896#M18139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I lifted some script text out of the help documentation, but nothing happens when I run it in the python window.&amp;nbsp; It appears that the list of rasters returns empty, as the script starts and then finishes in less than one second. I'm new to python, so am not even sure where to begin troubleshooting.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(See script posted in third reply, below)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2011 14:29:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233896#M18139</guid>
      <dc:creator>MarkEllis</dc:creator>
      <dc:date>2011-06-13T14:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: Basic ?: Script to apply color map not working, need help</title>
      <link>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233897#M18140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Going through the python window in ArcMap has only made this more confusing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Going line by line, there are no errors until the 'for raster in rasterList' line - &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;F2 returns a parsing error "expected an indented block"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit script or clear and reload with an indent,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;F2 returns a parsing error "unexpected indent"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Really? How does one fix this? The Help documentation is worthless for details like this, any guidance from a user would be appreciated.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2011 19:33:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233897#M18140</guid>
      <dc:creator>MarkEllis</dc:creator>
      <dc:date>2011-06-13T19:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Basic ?: Script to apply color map not working, need help</title>
      <link>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233898#M18141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you post the code inside &lt;PRE&gt; tags (see above the text box when posting), we can see your indentation (which is important in Python, btw).&lt;/PRE&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jun 2011 19:47:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233898#M18141</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-06-13T19:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Basic ?: Script to apply color map not working, need help</title>
      <link>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233899#M18142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Reposted script with code tags...&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;## Add color map to DRGs
##====================================
import arcpy
from arcpy import env

 # Set workspace
arcpy.env.workspace = "Y:\base_data\State\IL\100k_DRGs"

 # Get list of grids
rasterList = arcpy.ListRasters("*", "GRID")

&amp;nbsp;&amp;nbsp; for raster in rasterList:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ## Add Colormap
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ##Assign colormap using clr file
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddColormap_management(raster, "#", "ISA_DRG.clr")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print raster

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Add Colormap example failed."
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:49:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233899#M18142</guid>
      <dc:creator>MarkEllis</dc:creator>
      <dc:date>2021-12-11T11:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: Basic ?: Script to apply color map not working, need help</title>
      <link>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233900#M18143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The problem is that your "for" is indented. You only indent &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;after &lt;/SPAN&gt;&lt;SPAN&gt;the colon (ie. after the "for").&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jun 2011 14:58:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233900#M18143</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2011-06-14T14:58:19Z</dc:date>
    </item>
    <item>
      <title>Re: Basic ?: Script to apply color map not working, need help</title>
      <link>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233901#M18144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the tip!&amp;nbsp; I also noted in documentation that the workspace path should contain / instead of \, as the latter is a line continuation character in python.&amp;nbsp; The two changes together worked, it is now running.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Syntax is tricky for the beginner...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jun 2011 15:34:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/basic-script-to-apply-color-map-not-working-need/m-p/233901#M18144</guid>
      <dc:creator>MarkEllis</dc:creator>
      <dc:date>2011-06-14T15:34:52Z</dc:date>
    </item>
  </channel>
</rss>

