Using ArcMap 10.3, I would like to Select By Location multiple layers using ArcPy. The error message states line 7 is not correct. I can't find the error though. "Water_Body_Boundary" is my source layer.
import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") bldgLayer = "Water_Body_Boundary" layers = arcpy.mapping.ListLayers(mxd) for layer in layers: if layer.name != bldgLayer: arcpy.SelectLayerByLocation_management(layer, "WITHIN", bldgLayer)
The error message:
Runtime error Traceback (most recent call last): File "", line 7, in File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\management.py", line 7359, in SelectLayerByLocation raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000840: The value is not a Feature Layer. ERROR 000840: The value is not a Raster Catalog Layer. ERROR 000840: The value is not a Mosaic Layer. Failed to execute (SelectLayerByLocation)