AnsweredAssumed Answered

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

Question asked by cheynm@yahoo.com 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 http://forums.arcgis.com/threads/49556-how-to-access-map-document-layers-in-a-python-script-tool.

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\management.py", line 6559, in SelectLayerByLocation raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000368: Invalid input data.

I read http://resources.arcgis.com/en/help/main/10.1/#/Authoring_geoprocessing_tasks_with_Python_scripts/00570000007r000000/ 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.....   ;-)

Outcomes