Python Script not working as Tool

2637
3
Jump to solution
11-13-2015 08:05 AM
KellyZiegenfuss2
New Contributor

Hi All,

I have a script that works in python, but when I create a tool for it, it no longer works. I have attached the code, does anybody know what could be wrong? I have also copy and pasted the error I received. Thanks!

Executing: StreetNames "C:\Users\kziegenfuss\Desktop\PM\Segments Shapefile\Segments.shp" Street C:\Users\kziegenfuss\Desktop\PM\Clip\Clip.shp ROAD_NAME
Start Time: Fri Nov 13 07:54:58 2015
Running script StreetNames...
Failed script StreetNames...

Traceback (most recent call last):
  File "C:\Users\kziegenfuss\AppData\Roaming\ESRI\Desktop10.2\ArcToolbox\My Toolboxes\StreetName.tbx#StreetNames.py", line 29, in <module>
  File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 6812, in SelectLayerByLocation
    raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000368: Invalid input data.
Failed to execute (SelectLayerByLocation).

Failed to execute (StreetNames).
Failed at Fri Nov 13 08:02:24 2015 (Elapsed Time: 7 minutes 26 seconds)

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LukeSturtevant
Occasional Contributor III

The error indicates there is a problem with your inputs for the select layer by location. You need to generate a layer from the buffer in your script. The select layer by location will only take layer files not output features.

#buffer the dissolved Centerlines layer
arcpy.Buffer_analysis ("lyr_dissolved", "buffer", "50 Feet", "", "", "", "")

arcpy.MakeFeatureLayer_management("buffer", "lyr_buffer")

#Delete any centerlines that will not be used
arcpy.SelectLayerByLocation_management("lyr_buffer","INTERSECT","lyr_Segments","","NEW_SELECTION")

View solution in original post

3 Replies
DanPatterson_Retired
MVP Emeritus

What are the parameters for the tool?  a screen grab or documentation of the parameter, type, etc would be useful

0 Kudos
KellyZiegenfuss2
New Contributor

The parameters two shapefiles and a specified field from each shapefile

0 Kudos
LukeSturtevant
Occasional Contributor III

The error indicates there is a problem with your inputs for the select layer by location. You need to generate a layer from the buffer in your script. The select layer by location will only take layer files not output features.

#buffer the dissolved Centerlines layer
arcpy.Buffer_analysis ("lyr_dissolved", "buffer", "50 Feet", "", "", "", "")

arcpy.MakeFeatureLayer_management("buffer", "lyr_buffer")

#Delete any centerlines that will not be used
arcpy.SelectLayerByLocation_management("lyr_buffer","INTERSECT","lyr_Segments","","NEW_SELECTION")