Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Proper syntax for Select Feature Layer by Location

$
0
0

Can someone let me know how I can use a single feature from one layer as the “Select Features” when using the Make Feature Layer by Location tool with another layer as the input?

In the code below I have no idea what to put in place of BLAH to get this to run. Suggestions?

import arcpy

Practice_Sales1 = "Practice_Sales1"
Practice_Stops = "Practice_Stops"



import arcpy
fc = "y:/Practice_Sales1.shp"
field = "BOROUGH"
cursor = arcpy.SearchCursor(fc)

# Iterate through the rows in the cursor
for row in cursor:

    #Create Layer from the current row in the Practice_Sales1 file
     arcpy.MakeFeatureLayer_management("Practice_Sales.shp", "Sales_lyr", BLAH)

    # Select all features in Practice_Stops within 1000 feet of the current row in Practice_Sales1
    arcpy.SelectLayerByLocation_management(Practice_Stops, "WITHIN_A_DISTANCE", "Sales_lyr", "1000 Feet", "NEW_SELECTION", "NOT_INVERT")

    # Returns the # of selected features
    arcpy.GetCount_management(Practice_Stops)

    # Replace row value in COUNT field with 
    row.setValue("COUNT", arcpy.GetCount_management(Practice_Stops))

Viewing all articles
Browse latest Browse all 767

Trending Articles