Dynamically changing layer's symbology on a GP service

05-27-2015 01:03 PM
New Contributor


I'm working on a model with model builder.

At the end of the process i want to set the symbology using "Apply symbology from layer" tool.

The .lyr file varies by the input of the process. I'm doing this using "calculate value" tool.

Here is the code in the calculate value:

def x(num):

if num==2:

  return "C:\\tmp\GisSql.tmp2.lyr"

return "C:\\tmp\GisSql.tmp3.lyr"

now, the model runs perfectly on my local machine, including the symbology decision above.

but after publishing and trying to run it i get an error:

  • esriJobMessageTypeError: ERROR 000229: Cannot open c:\arcgisserver\directories\arcgisjobs\test\model_nafa_bar_chart_gpserver\jd3923b869c2f4389a24e3bceb8b36236\scratch\tmp\GisSql.tmp2.lyr

Well, i understand the problem. The .lyr file was not copied to the server, or the server cant find it for any other reason.

The question is, how can i dynamically change the symbology of a geo process?

I tried registering the "c:\tmp" folder with with the server - with no luck.

Any advice? I've spent hours on this..

4 Replies
Occasional Contributor II

I have the same problem. I have written a python script which should apply a symbology from a lyr file to the output layer. The path to the file is hard coded in the script. The folder has read acces for the user of the ArcGIS for Server Windows service. The tool ApplySymbologyFromLayer_management does not fire an exception. But in the map service of the gp service, the applied symbology does not show up. The features are always symbolized with the symbology used when publishing the geoprocessing service.

features = arcpy.GetParameterAsText(0)
whereClause = arcpy.GetParameterAsText(1)
arcpy.MakeFeatureLayer_management(features, "layerName", whereClause)
symbology = 'C:\\data\\gp\\mysymbology.lyr'
arcpy.ApplySymbologyFromLayer_management("layerName", symbology)
arcpy.SetParameterAsText(2, "layerName")
0 Kudos
by Anonymous User
Not applicable

Any luck on this ?? I'm trying to do the same thing

0 Kudos
New Contributor


Has there been any luck on this issue? Either with the two options below work in ArcGIS Pro 2.5, but does not contain symbology in the Geoprocessing Widget in WAB:

# Method 1 - ApplySymbologyFromLayer():
arcpy.ApplySymbologyFromLayer("layer_PATH", "symbology_PATH")

# Method 2 - parameters[1].symbology:
parameters[1].symbology = "symbology_PATH"


Does anyone have any help on preserving symbology from a layer file (".lyrx") in the output of a geoprocessing service? It simply is not preserved for me.

0 Kudos
New Contributor II

anybody have any luck with this? I realllllllllly need this figured out for a custom GP service I built too.

0 Kudos