AnsweredAssumed Answered

Select by location for the row in a search cursor

Question asked by Carusot42 on Jan 6, 2015
Latest reply on Jan 6, 2015 by Carusot42

Hi folks,

 

I'm trying to use a search cursor to iterate through a table and select the nearest centroids to the feature in the cursor, but when I try this instead of only selecting the centroids nearest the point in the cursor, it instead selects all of the centroids that distance from all of the points, then iterates to the next feature and selects all of them again. Is it possible to make the SelectLayerByLocation_management function only select features based on a single point at a time?

 

Here's the code I'm using:

# Create search cursor which will iterate through wells, selecting all centroids within a distance 
with arcpy.da.SearchCursor(wells, ["OBJECTID"]) as cursor:
        for row in cursor:
                # select by location
                arcpy.SelectLayerByLocation_management("orps09_FL", "WITHIN_A_DISTANCE", wells, "0.5 kilometers", "NEW_SELECTION")

 

 

Thanks in advance,

 

Tom

Outcomes