Quantcast
Channel: Forums - Geoprocessing
Viewing all articles
Browse latest Browse all 1952

Creating a layer in Geoprocessing Service causes an error

$
0
0
I have some logic in my Geoprocessing service that creates a layer in order to add it to a map.

1. mxd = arcpy.mapping.MapDocument(map_document)
2. df = arcpy.mapping.ListDataFrames(mxd)[0]
3. arcpy.management.MakeFeatureLayer(out_zone, "layer") #out_zone is an in_memory fc
4. buffer_layer = arcpy.mapping.Layer("layer") #this doesn't work in the gp service
5. arcpy.mapping.AddLayer(df, buffer_layer, "TOP")

This works just fine in the script tool from ArcMap. It publishes successfully as well. But when I run the GP service I get an error on line 4 above. I have some traceback error reporting and it says the line that is failing is:

buffer_layer = arcpy.mapping.Layer(g_Esri_variable_3)

The error I get is Object: CreateObject layer invalid data source

So my question is what is g_Esri_variable_3? What is ArcGIS Server doing differently than the desktop script tool? Any suggestions on fixing this?

Viewing all articles
Browse latest Browse all 1952

Trending Articles