Getting full path of layer selected in drop-down box for ArcGIS Python script tool?

I had the same issue a while back. It's a pretty easy fix, just use the the describe tool.

Your already getting the layer name from your parameters. So all you have to do is describe the layer, find the path then merge the two.

layer = arcpy.GetParameterAsText(0)
desc = arcpy.Describe(layer)
path = desc.path
layersource = str(path) + "/" + layer

That should do it no problem.

Hope this helps


If you want to account for the possibility that the user might specify a raster within the filesystem:

from os.path import split, join
layer = arcpy.GetParameterAsText(0)

#Check if there is a path on the input parameter. If not, prepend the path.
if not split(layer)[0]:
    layer = join(arcpy.Describe(layer).path, "{}.tif".format(layer))

There is a little bit shorter way to do this also. describe data objects have a catalogPath property which is the full path to the file.

With the 10.1 version we're using, you can do:

layer = arcpy.GetParameterAsText(0)
desc = arcpy.Describe(layer)
layersource = desc.catalogPath