2

When i trying to do Select by location i got : arcgis scripting. ExecuteError: Failed to execute. Parameters are not valid. ERROR 000368: Invalid input data. Failed to execute (SelectLayerByLocation)

I am trying to excecute select by location on current selected feature after select by attribute.

env.workspace = "C:\temp"

input = 'C:\\temp\M0TASHT\M0TASHT.gdb\sLine'
input1= 'C:\\temp\M0TASHT\M0TASHT.gdb\sManhole'
arcpy.MakeFeatureLayer_management('sManhole', 'sManhole_lyr')
in_features = 'sManhole_lyr'
where_clause = '"ManholeSubtype" = ('"4515" ')'
arcpy.SelectLayerByAttribute_management(in_features, "NEW_SELECTION", where_clause)
arcpy.SelectLayerByLocation_management("C:\\temp\M0TASHT\M0TASHT.gdb\sLine", "INTERSECT", "sManhole_lyr", "", "NEW_SELECTION")
0

1 Answer 1

8

Instead of

"C:\\temp\M0TASHT\M0TASHT.gdb\sLine"

you need to double all your back slashes to escape them i.e.

"C:\\temp\\M0TASHT\\M0TASHT.gdb\\sLine"

And instead of

where_clause = '"ManholeSubtype" = ('"4515" ')'

Try

where_clause = ' "ManholeSubtype" = ' + " '4515' "

Or

where_clause = ' ' ' "ManholeSubtype" = 4515 ' ' '

Which will depend on whether the field is text or integer.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.