I am working on a tool in a python toolbox and am totally confused about what is going on and causing my select by location operation to fail (Error 000368).

I am trying to select the features in one layer that are completely within a specific polygon. Here is the line where the error is occuring:

for (index,item) in enumerate(TempIDs):         
    lyrBoundaries.definitionQuery = "[" + parameters[1].valueAsText + "]" + " = " + "'" + str(item) + "'"

    for (index2,item2) in enumerate(Spec_Layers):
        currentLayer = arcpy.mapping.Layer(str(item2))



The error is occurring in the arcpy.SelectLayerByLocation_management() line. The text of the error message I'm getting is: (edited to remove the actual text of the path)

    Executing: SelectLayerByLocation "[FULL PATH OF currentLayer]" COMPLETELY_WITHIN GPL0 "0 Unknown" NEW_SELECTION
Start Time: Fri Mar 01 10:29:29 2013
Failed to execute. Parameters are not valid.
ERROR 000368: Invalid input data.

My question is really: Why is lyrBoundaries showing up as GPL0 and not as the path of the layer? Beyond that, any tips or hints about why the inputs are being interpreted as invalid?

2 Answers 2


I realized that my problem was coming from the extra step of trying to dynamically recreate a layer for every entry in Spec_Layers. This value was being set from a multivalue input in the tool, which returns a list of objects which are already instantiated as Layer objects (so, no need to make a layer out of a layer).

This is working for me nicely: (parameters[2].values is the list of Layer objects returned from the list of Layers chosen in the tool dialog box)

for (index,item) in enumerate(TempIDs):

lyrBoundaries.definitionQuery = "[" + parameters[1].valueAsText + "]" + " = " + "'" + str(item) + "'"

messages.addMessage("Associating Data for: " + str(lyrBoundaries.definitionQuery))

for (index2,item2) in enumerate(parameters[2].values):

    #Select all of the features in the current layer that are completely within the current Site Boundary

    #Set hopper equal to the current value of TempID
    hopper = '"' + str(item) + '"'

I recommend that you create currentlayer using arcpy.MakeFeatureLayer instead of arcpy.mapping.Layer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.