The symbologyType on the Layer object is a read-only property. In other words, you can't change a raster classified symbology to a raster unique value symbology. You can only change the properties for a specific symbology class on a layer. The only way to change the symbology type is by publishing the desired result to a layer file and using the UpdateLayer function.
...stuff happens... density = "C:\MyGDB.gdb\density" tempDens = KernelDensity(datapoints, "NONE","#","#","SQUARE_MAP_UNITS") arcpy.CopyRaster_management(tempDens, density) # This adds the output raster to the map. It works, except the raster is only added as a layer after the script finishes parameters[7].value = density mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd)[0] lyrList = arcpy.mapping.ListLayers(mxd,"",df) # This indicates there are zero layers at this point, even though the output parameter was set above messages.addMessage("There are {0} layers in the dataframe.".format(len(lyrList)) # This produces nothing, since the layer isn't in the map densLyr = arcpy.mapping.ListLayers(mxd,"density",df)[0] messages.addMessage("Layer name is: {0}".format(densLyr.name))
arcpy.mapping.AddLayer(df,density)
Solved! Go to Solution.
def getParametersInfo(self): outDensity = arcpy.Parameter( displayName = "Kernel Density", name = "outDensity", datatype = "DERasterDataset", parameterType = "Derived", direction = "Output") outDensity.symbology = "C:\path_to_my_layer_file.lyr"
symbology = "C:\symbology.lyr" parameters[7].value = density parameters[7].symbology = symbology
def getParametersInfo(self): outDensity = arcpy.Parameter( displayName = "Kernel Density", name = "outDensity", datatype = "DERasterDataset", parameterType = "Derived", direction = "Output") outDensity.symbology = "C:\path_to_my_layer_file.lyr"