Select to view content in your preferred language

SelectLayerByLocation blowing out

89
1
yesterday
JeffHanson2
New Contributor III

I'm trying to take a point in a search cursor and then find what section it is in.   I have a bioFC and a "sec_lyr" and I am passing in the feature from the cursor - looping through the cursor.   It is not working.   How can I iterate one point feature at a time?

 

    cursor = arcpy.da.SearchCursor(bioFC, ["Twp_Sec_Rng"])
    arcpy.MakeFeatureLayer_management(secFC, "sec_lyr")
    # loop one, is a search cursor
    print("Processing data...")
    for fea in cursor:
        arcpy.SelectLayerByLocation_management("sec_lyr", "intersect", fea)
0 Kudos
1 Reply
DavidSolari
Occasional Contributor III

If you have a bunch of features and you want to see their spatial relation to another set of features just use the Spatial Join tool. You can run through the results with a cursor but it'll run much faster, especially as the size of your datasets expand.

0 Kudos