<?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: Cannot put a layer name as the same as the raster name just created by Python script. :( in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/cannot-put-a-layer-name-as-the-same-as-the-raster/m-p/609016#M47535</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is a bit difficult to deduce what may be the error based only on a mall part of the code, but in case you use the variable "layername" for other layers that are being created you should use arcpy.env.overwriteOuput = True or use unique names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please next time when posting code, use the syntax highlighting:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/1070" target="_blank"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then your code would look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Script arguments
heatMapTest2 = Output_Raster_Layer
heatMapTest2Name = 'Output Raster'
templist = heatMapTest2.split("\\")
layername = templist[-1]
MXD = arcpy.mapping.MapDocument("CURRENT")
dataFrame = arcpy.mapping.ListDataFrames(MXD)[0]
mapExtent = dataFrame.extent
scale = dataFrame.scale
Input_Layer_2 = Input_Layer

#Add new layer to the dataframe
result = arcpy.MakeRasterLayer_management(heatMapTest2, layername)
lyrLayer = result.getOutput(0)
arcpy.mapping.AddLayer(dataFrame, lyrLayer, "AUTO_ARRANGE")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 02:03:55 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2021-12-12T02:03:55Z</dc:date>
    <item>
      <title>Cannot put a layer name as the same as the raster name just created by Python script. :(</title>
      <link>https://community.esri.com/t5/python-questions/cannot-put-a-layer-name-as-the-same-as-the-raster/m-p/609013#M47532</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a question regarding Python script for making a Heat Map Tool.&lt;/P&gt;&lt;P&gt;I&amp;nbsp; am making a Heat Map Tool where users can set the map extent, the tool will read the current scale of the map, then make a raster heat map layer using appropriate cell size and search radius depend on the map scale, and the new raster layer will appear on the TOC of the map document. I succeeded this part. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;But I also put a function that users can set the raster name, and the name will appear as a layer name too. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/cool.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script is the below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #7ed529;"&gt;&lt;STRONG&gt;# Script arguments&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;heatMapTest2 = Output_Raster_Layer&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;heatMapTest2Name = 'Output Raster'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;templist = heatMapTest2.split("\\")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;layername = templist[-1]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MXD = arcpy.mapping.MapDocument("CURRENT")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;dataFrame = arcpy.mapping.ListDataFrames(MXD)[0]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;mapExtent = dataFrame.extent&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;scale = dataFrame.scale&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Input_Layer_2 = Input_Layer&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #7ed529;"&gt;&lt;STRONG&gt;#Add new layer to the dataframe&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;result = arcpy.MakeRasterLayer_management(heatMapTest2, layername)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;lyrLayer = result.getOutput(0)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;arcpy.mapping.AddLayer(dataFrame, lyrLayer, "AUTO_ARRANGE")&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This function does work if I use the ArcGIS from the remote, and the work environment is the same server as the remote. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;But I set the work environment in different server, it gives me an error message as the below.&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/cry.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;Traceback (most recent call last):&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;&amp;nbsp; File "Q:\GIS_Tools\HeatMapTool\Python\HeatMapTool_Incidents_Add_Reclass_para5_short.py", line 149, in &amp;lt;module&amp;gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = arcpy.MakeRasterLayer_management(heatMapTest2, layername)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6479, in MakeRasterLayer&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;ExecuteError: ERROR 000582: Error occurred during execution.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;Failed to execute (HeatMapAllWithOutputLayerPara).&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/info.png" /&gt; (line 149 is &lt;STRONG&gt;result = arcpy.MakeRasterLayer_management(heatMapTest2, layername)&lt;/STRONG&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there anybody who can tell why that happened? &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/shocked.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Jul 2014 22:07:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-put-a-layer-name-as-the-same-as-the-raster/m-p/609013#M47532</guid>
      <dc:creator>HiroyukiMatsuda</dc:creator>
      <dc:date>2014-07-22T22:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot put a layer name as the same as the raster name just created by Python script. :(</title>
      <link>https://community.esri.com/t5/python-questions/cannot-put-a-layer-name-as-the-same-as-the-raster/m-p/609014#M47533</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I wouldn't use the result like that, rather you should use the layername variable in your call to add layer:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7ed529;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;#Add new layer to the dataframe&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;arcpy.MakeRasterLayer_management(heatMapTest2, layername)&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;arcpy.mapping.AddLayer(dataFrame, &lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;layername&lt;/STRONG&gt;, "AUTO_ARRANGE")&lt;/STRONG&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 18:30:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-put-a-layer-name-as-the-same-as-the-raster/m-p/609014#M47533</guid>
      <dc:creator>MatSavage1</dc:creator>
      <dc:date>2014-07-24T18:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot put a layer name as the same as the raster name just created by Python script. :(</title>
      <link>https://community.esri.com/t5/python-questions/cannot-put-a-layer-name-as-the-same-as-the-raster/m-p/609015#M47534</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the reply.&lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt; I tried, but am still getting an error message like the below. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/cry.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Traceback (most recent call last):&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; File "Q:\GIS_Tools\HeatMapTool\Python\HeatMapTool_Incidents_Add_Reclass_para5_revised_072414.py", line 149, in &amp;lt;module&amp;gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeRasterLayer_management(heatMapTest2, layername)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6479, in MakeRasterLayer&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise e&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;ExecuteError: ERROR 000582: Error occurred during execution.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;Failed to execute (HeatMapAllWithOutputLayerParaRevised072414).&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Failed at Thu Jul 24 17:43:35 2014 (Elapsed Time: 14.72 seconds)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Jul 2014 21:47:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-put-a-layer-name-as-the-same-as-the-raster/m-p/609015#M47534</guid>
      <dc:creator>HiroyukiMatsuda</dc:creator>
      <dc:date>2014-07-24T21:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot put a layer name as the same as the raster name just created by Python script. :(</title>
      <link>https://community.esri.com/t5/python-questions/cannot-put-a-layer-name-as-the-same-as-the-raster/m-p/609016#M47535</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is a bit difficult to deduce what may be the error based only on a mall part of the code, but in case you use the variable "layername" for other layers that are being created you should use arcpy.env.overwriteOuput = True or use unique names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please next time when posting code, use the syntax highlighting:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/1070" target="_blank"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then your code would look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Script arguments
heatMapTest2 = Output_Raster_Layer
heatMapTest2Name = 'Output Raster'
templist = heatMapTest2.split("\\")
layername = templist[-1]
MXD = arcpy.mapping.MapDocument("CURRENT")
dataFrame = arcpy.mapping.ListDataFrames(MXD)[0]
mapExtent = dataFrame.extent
scale = dataFrame.scale
Input_Layer_2 = Input_Layer

#Add new layer to the dataframe
result = arcpy.MakeRasterLayer_management(heatMapTest2, layername)
lyrLayer = result.getOutput(0)
arcpy.mapping.AddLayer(dataFrame, lyrLayer, "AUTO_ARRANGE")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:03:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cannot-put-a-layer-name-as-the-same-as-the-raster/m-p/609016#M47535</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T02:03:55Z</dc:date>
    </item>
  </channel>
</rss>

