ERROR 000732: Selecting Features: Dataset inpath2 does not exist or is not supported

1081
1
12-26-2022 02:16 AM
ArannaykFoundation
New Contributor

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)

Tags (1)
0 Kudos
1 Reply
DanPatterson
MVP Esteemed Contributor

selection = arcpy.SelectLayerByLocation_management("inPath", "WITHIN_A_DISTANCE", "inpath2",  ......

inPath and inpath2  should not be in double quotes ( " ") since they are variables


... sort of retired...
0 Kudos