I am trying to create a script tool using python where I will select location by area and export the area in the directory. To do so I have used this script
import arcpy arcpy.env.overwriteOutput = True try: inPath = arcpy.GetParameterAsText(0) inpath2 = arcpy.GetParameterAsText(1) outPath = arcpy.GetParameterAsText(2) selection = arcpy.SelectLayerByLocation_management("inPath", "WITHIN_A_DISTANCE", "inpath2", "50 meter","NEW_SELECTION","NOT_INVERT") copySelection = arcpy.CopyFeatures_management(selection,outPath) arcpy.GetMessage("All Done") except: arcpy.AddError("Could not colplete the process") arcpy.AddMessage(arcpy.GetMessages())
but it gives following message
ERROR: Could not complpete the process
Start Time: Monday, December 26, 2022 3:54:13 PM
Failed to execute. Parameters are not valid.
ERROR 000368: Invalid input data.
ERROR 000732: Selecting Features: Dataset inpath2 does not exist or is not supported
Failed to execute (SelectLayerByLocation).
Failed at Monday, December 26, 2022 3:54:13 PM (Elapsed Time: 0.00 seconds)
selection = arcpy.SelectLayerByLocation_management("inPath", "WITHIN_A_DISTANCE", "inpath2", ......
inPath and inpath2 should not be in double quotes ( " ") since they are variables