Arcpy GPServer - Group Layer as Result Map Service

268
1
10-23-2017 02:20 AM
tolgastertolgaster
New Contributor

Hello,

When I publish the KmlToLayer as below, I can publish the Group Layer as a map service. Gp Server publishes group layer parameter type as GpString and can display it as Map Service.

But when I try to do the same output with Arcpy as follows, the lyr file is only recognized as a file and the result map service is empty.

result_gl = arcpy.mapping.ListLayers(mxd, "GroupLayer", df)[0]
# ...
result_group_layer_path = arcpy.env.scratchWorkspace + "\\" + "scratch.lyr"
arcpy.SaveToLayerFile_management(result_gl , result_group_layer_path)
# ...
# Only this one adds result layer to display others not.
arcpy.SetParameterAsText(1, result_group_layer_path)‍‍‍‍‍‍‍‍‍‍‍‍
# Or
# arcpy.SetParameter(1, result_gl)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
# Or
# arcpy.SetParameter(1, arcpy.mapping.Layer(result_group_layer_path))‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 ‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

When I publish this with "View results with a map service option" , the output parameter is as follows not as a map service.

{
 "paramName": "RESULT",
 "dataType": "GPDataFile",
 "value": {
  "url": "https://....gpserver/j069a1ca799304125882f8e172a4626b5/scratch/scratch.lyr"
 }
}‍‍‍‍‍‍‍

What is the difference between the KmlToLayer model above and the my ArcPy model outputs?

What should I do in order for the ArcGIS server to display the result lyr file (group layer) as a map service?

0 Kudos
1 Reply
tolgastertolgaster
New Contributor

The real problem I want to address above is: I am generating an unknown number of raster layers as a result of my model. Since the result parameter count is not definite, I want to create the group layer dynamically and publish it as a single result parameter (group layer).


Has anyone ever had to produce dynamic output layers?  or is there something I'm doing all wrong?

0 Kudos