<?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: Loading a raster into a dataframe in arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/loading-a-raster-into-a-dataframe-in-arcpy/m-p/468364#M36550</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You'll need to save a raster layer as a .lyr file to disk with the symbology you want, then use arcpy.mapping.Layer to open the layer file and set the dataSoruce attribute to the source of the new raster you've created.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 04 Feb 2011 17:34:21 GMT</pubDate>
    <dc:creator>JasonScheirer</dc:creator>
    <dc:date>2011-02-04T17:34:21Z</dc:date>
    <item>
      <title>Loading a raster into a dataframe in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/loading-a-raster-into-a-dataframe-in-arcpy/m-p/468363#M36549</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;When attempting to load a raster (created in arcpy) using arcpy.mapping.AddLayer, I get the following error message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;type 'exceptions.AssertionError'&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's a snippet of the code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
env.workspace = arcpy.GetParameterAsText(0)
...
YmapFile&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.GetParameterAsText(4) # Output filename
...
YMAP = arcpy.NumPyArrayToRaster(YmapArray,lowerLeft,pixSize,pixSize)
YMAP.save(YmapFile)
...
mxd = arcpy.mapping.MapDocument("CURRENT")
df&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.mapping.ListDataFrames(mxd)[0]
arcpy.MakeRasterLayer_management(YmapFile,"Y Map")
arcpy.mapping.AddLayer(df,"Y Map", "BOTTOM")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The raster is properly created and saved in the folder/geodatabase defined by env.workspace.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I can load the raster layer using the arcpy.SetParameterAsText() function (when the parameter is set as a derived entity in the scipt's properties option box), so I know that the layer is being properly created.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:31:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loading-a-raster-into-a-dataframe-in-arcpy/m-p/468363#M36549</guid>
      <dc:creator>MannyGimond</dc:creator>
      <dc:date>2021-12-12T16:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Loading a raster into a dataframe in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/loading-a-raster-into-a-dataframe-in-arcpy/m-p/468364#M36550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You'll need to save a raster layer as a .lyr file to disk with the symbology you want, then use arcpy.mapping.Layer to open the layer file and set the dataSoruce attribute to the source of the new raster you've created.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Feb 2011 17:34:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loading-a-raster-into-a-dataframe-in-arcpy/m-p/468364#M36550</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2011-02-04T17:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: Layer points to .afr file</title>
      <link>https://community.esri.com/t5/python-questions/loading-a-raster-into-a-dataframe-in-arcpy/m-p/468365#M36551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Jason. Saving the layer to a file was the missing link to the workflow. Here's the modified "working" code snippet:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;env.workspace = arcpy.GetParameterAsText(0)&lt;BR /&gt;...&lt;BR /&gt;YmapFile&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.GetParameterAsText(4) # Output filename&lt;BR /&gt;...&lt;BR /&gt;YMAP = arcpy.NumPyArrayToRaster(YmapArray,lowerLeft,pixSize,pixSize)&lt;BR /&gt;YMAP.save(YmapFile)&lt;BR /&gt;...&lt;BR /&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;BR /&gt;df&amp;nbsp;&amp;nbsp;&amp;nbsp; = arcpy.mapping.ListDataFrames(mxd)[0]&lt;BR /&gt;arcpy.MakeRasterLayer_management(YmapFile,"Y Map")&lt;BR /&gt;ymapLyr = arcpy.mapping.Layer(r"c:/tmp/YMAP.lyr")&lt;BR /&gt;arcpy.mapping.AddLayer(df, ymapLyr,"BOTTOM")&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm now encountering another stumbling block. &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;arcpy.mapping.Layer&lt;/SPAN&gt;&lt;SPAN&gt; is saving a layer file that points to some obscure C:\Users\jdoeL\AppData\Local\Temp\19374123947128412.xc8915868_b3b2_4d7b_9bc6_aec2e2cbbc89y0.afr file (the raster layer it should point to is in a different folder/geodatabase). Oddly, if the raster layer is removed from its location, the layer file link is broken (indicating that the *.afr is a pointer to a pointer?). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This poses a problem when I attempt to use that layer in a Raster Calculator operation. The geoprocessing does not seem to like the .afr pointer. Any idea what I may be doing wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using 10 SP1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Feb 2011 13:51:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/loading-a-raster-into-a-dataframe-in-arcpy/m-p/468365#M36551</guid>
      <dc:creator>MannyGimond</dc:creator>
      <dc:date>2011-02-07T13:51:29Z</dc:date>
    </item>
  </channel>
</rss>

