AnsweredAssumed Answered

Selecting Features by Location

Question asked by lavpizzo on Jun 11, 2012
Latest reply on Jun 13, 2012 by lavpizzo

I am trying to select features by location from the "tableName_vctor" layer as defined (and highlighted in red), then export them to a new shapefile and am receiving the following errors (refer to the blue section):

ERROR 000622: Failed to execute (Select Layer By Location). Parameters are not valid.
ERROR 000628: Cannot set input into parameter search_distance.

any insight as to how to fix these errors is much appreciated

thank-you in advance!

    # Iterates through each of the input text files
    for v in list(table):
        # Removes the file extension
        tableName = os.path.splitext(v)[0]
        # Variables
        tableName_line = tableName + str("_line.shp")
        tableName_vctor = tableName + str("_vctor.shp")
        tableName_e = tableName + str ("_e.shp")
        gate = r"C:\gis\gate.shp"
        tableName_sim = tableName + str("_sim.shp")

        # Creating vectors from xy coordinates
        gp.Toolbox = r"C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Military Analyst Tools.tbx"
        gp.TableToLine_ma(v, tableName_line, "Decimal Degrees", "sLat", "sLon", "eLat", "eLon", "False", "False")
        gp.Project_management(tableName_line, tableName_vctor, "PROJCS['LCC']")

        #Selecting vectors that intersect a line, then points that intersect the vector, then removing the initial selection
        gp.SelectLayerByLocation(tableName_vctor, "intersect", gate, "NEW_SELECTION")
        gp.SelectLayerByLocation(tableName_e, "intersect", tableName_vctor, "ADD_TO_SELECTION")
        gp.SelectLayerByLocation(tableName_vctor, "intersect", gate, "REMOVE_FROM_SELECTION")

        # Write the selected features to a new feature class in the folder
        gp.CopyFeatures(tableName_sim, r"C:\gis\temp")
    #If an error occurred while running the script, then print the messages
    print gp.GetMessages()