AnsweredAssumed Answered

How to refer to layers from Python in an ArcGIS Server 10.1 Geoprocessing service?

Question asked by on Mar 27, 2013
Latest reply on May 29, 2013 by khibma-esristaff
Last year when getting started with 10.0 GP services I asked

Now this year I'm getting started with 10.1 and its "publish a Result" scheme, and the script from last year doesn't work when published as a service.

The script tool references ArcSDE layers by their TOC name:

layername = "Flowlines" result = arcpy.SelectLayerByLocation_management(layername, "WITHIN_A_DISTANCE", inpointgeo, bufferradius, "NEW_SELECTION")

When I run it in ArcMap 10.1, it works fine if said layers exist in the map document open at the time I execute the tool. With a successful Result, I publish the service. Then I execute the service and get an error like:

result = arcpy.SelectLayerByLocation_management(layername, "WITHIN_A_DISTANCE", inpointgeo, bufferradius, "NEW_SELECTION") File "f:\program files\arcgis\server\arcpy\arcpy\", line 6559, in SelectLayerByLocation raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000368: Invalid input data.

I read which seems to suggest that the Analyze step should have recognized my use of an ArcSDE layer by name and (presumably) spool it up in the service by the same name, but then why am I joyless?

Thanks, I know this is remedial.....   ;-)