AnsweredAssumed Answered

arcpy.SelectLayerByLocation_management not working

Question asked by jramirez@irvineco on Aug 19, 2019
Latest reply on Aug 20, 2019 by bixb0012


I am new to python and arcpy, I have a script I am trying to get to work. It fails at the select layer by location. If I take out the select by location the script runs fine and the field calculates works. I feel like I am missing something simple but I just don't know.

import arcpy
# Set the workspace environment
arcpy.env.workspace = r"G:\GIS\ESRI\Staging\Survey123\Testing\New File Geodatabase.gdb"
print arcpy.ListFeatureClasses()
print("this is a list of feature classes")
# Select by location
arcpy.SelectLayerByLocation_management("propertypnts", "INTERSECT", "retailpt2", "", "NEW_SELECTION")
print("I have selected the features")
# Field Calculate
arcpy.CalculateField_management('propertypnts', "CompleteY_N",
                                '!CompleteY_N!.replace("Not Completed","Completed")', "Python_9.3")
print("Calculation done")

This is the error I get.


Traceback (most recent call last):
File "G:/GIS/ESRI/Staging/Survey123/Testing/", line 8, in <module>
arcpy.SelectLayerByLocation_management("propertypnts", "INTERSECT", "retailpt2", "", "NEW_SELECTION")
File "C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\", line 7891, in SelectLayerByLocation
raise e
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000368: Invalid input data.
Failed to execute (SelectLayerByLocation)


#Python arcpy