I'm working on ArcGIS 9.3.1 and I run a python script which basically does a "select by location" query to several SDE layers which appear on the ArcMAP TOC (using a polygon shapefile the user points to) and copies the selected features to a new shapefile.
THE PROBLEM IS that some layers are within a group layer, and then the script gives a error stating :
<class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000840: The value is not a Feature Layer. Failed to execute (SelectLayerByLocation)
now I understand that group layer is not a feature Layer and that SelectLayerByLocation only accepts feature Layers, that's where my question fits in:
Question: How can I reach a feature layer inside a Group layer using python code? or better yet, how can I tell what kind of layer I'm dealing with (Feature\group layer) using python code(describe method doesn't work on group)?
If your group layer name is "Infrastructure" and a layer w/in that group layer is "Streets", then you can find the group in Python with "Infrastructure\Streets"
Thanks for the quick response. However, it did not work - I tried this solution and got the following error message:
<class 'arcgisscripting.ExecuteError'>: Failed to execute. Parameters are not valid. ERROR 000732: Input Feature Layer: Dataset background\houses does not exist or is not supported Failed to execute (SelectLayerByLocation).
Are you running the script as a stand-alone script or as a script tool? In order to use layers, you need a script tool that's running 'inside' arcmap. See An overview of creating script tools for an explanation of script tools vs. stand-alone scripts.
Other than the above, I don't know why it's not working.
Hi, Dale - Thanks a million for trying to help me out.
I'm using a script tool - I run my script through ArcToolbox and a tool I built, so I guess your answer doesn't answer to my problem - but thanks, you've given me a idea to check maybe there is a tool background property that changing it will help me (i doubt it, but it's worth checking).
I'll return to say if this step will help in anyway but thanks in advance.