AnsweredAssumed Answered

Cannot put a layer name as the same as the raster name just created by Python script. :(

Question asked by hmatsuda on Jul 22, 2014
Latest reply on Jan 21, 2015 by xander_bakker

I have a question regarding Python script for making a Heat Map Tool.

I  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.

But I also put a function that users can set the raster name, and the name will appear as a layer name too.

 

The script is the below.

 

# 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")

 

This function does work if I use the ArcGIS from the remote, and the work environment is the same server as the remote.

But I set the work environment in different server, it gives me an error message as the below.

 

Traceback (most recent call last):

  File "Q:\GIS_Tools\HeatMapTool\Python\HeatMapTool_Incidents_Add_Reclass_para5_short.py", line 149, in <module>

    result = arcpy.MakeRasterLayer_management(heatMapTest2, layername)

  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6479, in MakeRasterLayer

    raise e

ExecuteError: ERROR 000582: Error occurred during execution.

Failed to execute (HeatMapAllWithOutputLayerPara).

(line 149 is result = arcpy.MakeRasterLayer_management(heatMapTest2, layername))

 

Is there anybody who can tell why that happened?

Outcomes