I'm trying to use
SelectLayerByLocation_managment in a script and keep getting the following error:
ExecuteError: Failed to execute. Parameters are not valid. ERROR 000368: Invalid input data. ERROR 000732: Selecting Features: Dataset pnrsLyr does not exist or is not supported Failed to execute (SelectLayerByLocation).
I made both feature classes into layers. When I run the same syntax in the Python command window in ArcMap it seems to work fine.
Here's the script:
import arcpy cities = r"C:\RS_Data\Python\Geog485\Lesson3\Lesson3PracticeExercises\Lesson3PracticeExerciseA\Washington.gdb\CityBoundaries" pnrs = r"C:\RS_Data\Python\Geog485\Lesson3\Lesson3PracticeExercises\Lesson3PracticeExerciseA\Washington.gdb\ParkAndRide" citiesLyr = arcpy.MakeFeatureLayer_management(cities) pnrsLyr = arcpy.MakeFeatureLayer_management(pnrs) print "made feature layers" nameField = "HasParkAndRide" selection = arcpy.SelectLayerByLocation_management("citiesLyr","INTERSECT","pnrsLyr")