Hey all,
I've got an arcpy question for you. I'm still new to python as well but I think i have a decent handle on it. But i'm not sure why this script isn't working. It's pretty basic but I keep getting an error. Can someone point out the issue for me? I'd really appreciate it.
import arcpy
mxd = arcpy.mapping.MapDocument(r'C:\Users\JOC-001\Documents\GIS\HSIP\Infrastructure\HSIP_Gold_2015_Infrastructure2.mxd')
layers = arcpy.mapping.ListLayers(mxd)
for lyr in layers:
arcpy.SelectLayerByLocation_management(lyr, "WITHIN_A_DISTANCE", r"C:\Users\JOC-001\Documents\ArcGIS\Default.gdb\Illinois", "50 Miles", "NEW_SELECTION")
arcpy.FeatureClassToFeatureClass_conversion(lyr, r'C:\Users\JOC-001\Documents\GIS\HSIP\IL_Infrastructure2015', lyr+'.shp')
And the error i'm receiving
Traceback (most recent call last):
File "C:\Users\JOC-001\Desktop\ArcGIS.py", line 7, in <module>
arcpy.SelectLayerByLocation_management(lyr, "WITHIN_A_DISTANCE", r"C:\Users\JOC-001\Documents\ArcGIS\Default.gdb\Illinois", "50 Miles", "NEW_SELECTION")
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 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).