cheynm@yahoo.com

how to access 'source map document' layer in a Python tool layer?

Discussion created by cheynm@yahoo.com on Feb 6, 2012
Latest reply on Feb 6, 2012 by khibma-esristaff
Hi - say I write a Python script tool that I intend to publish as a geoprocessing service. It takes simple datatype inputs and produces simple datatype outputs, but internally it uses geodata layers. I've added my tool as a 'tool layer' to a 'source map document', with the idea that each execution of my tool won't have to spool up the layer in memory, it will be cached in the document. The sort of stuff described in the ArcGIS 10 Help under 'Geoprocessing with ArcGIS Server', but all the examples use models, not script tools.

Somewhere in my python script I want to get ahold of a layer from the document. How do I do that?

In contrast, if I wanted my script to spool up the layer with each execution, I might do something like:

mylayer="mylayer"
arcpy.MakeFeatureLayer_management("C:/data/mydata.gdb/datasetname/featureclassname", mylayer)

Outcomes