AnsweredAssumed Answered

Python Error: arcpy.SelectLayerByLocation_management

Question asked by JerryGarcia on Sep 30, 2016
Latest reply on Sep 30, 2016 by JerryGarcia

See screen shot.

Any suggestions?

Thanks!!!

 

import arcpy

wk=r'C:\Users\Administrator\AppData\Roaming\Esri\Desktop10.3\ArcCatalog\GIS DataCreator.sde'

arcpy.env.workspace=wk

print arcpy.env.workspace

fcCounties = "GIS.DATACREATOR.counties"
fieldsCounties = ['OBJECTID_1', 'Shape', 'NAME']
print arcpy.Exists(fcCounties)

fcSections = "GIS.DATACREATOR.sections_test"
fieldsSections = ['OBJECTID', 'Shape', 'county']
print arcpy.Exists(fcSections)

arcpy.MakeFeatureLayer_management(fcSections, 'sections_lyr')
arcpy.MakeFeatureLayer_management(fcCounties, 'counties_lyr')

with arcpy.da.SearchCursor('counties_lyr', fieldsCounties) as cursor:
for row in cursor:
print row[1]
arcpy.SelectLayerByLocation_management('sections_lyr', row[1])

 

----------

 

Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>>
C:\Users\Administrator\AppData\Roaming\ESRI\Desktop10.3\ArcCatalog\GIS DataCreator.sde
True
True
(-9645043.375313655, 3833831.999483527)

Traceback (most recent call last):
File "E:\Python\relateCopyCounties.py", line 23, in <module>
arcpy.SelectLayerByLocation_management('sections_lyr', row[1])
File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 7359, in SelectLayerByLocation
raise e
RuntimeError: Object: Error in executing tool
>>>

Attachments

Outcomes