AnsweredAssumed Answered

can a geometry object be used with select layers by location?

Question asked by SeaforthGeo on Oct 2, 2020
Latest reply on Oct 6, 2020 by SeaforthGeo

I am trying to use Select Layers By Location tool in Python.

 

I have a polygon feature class that I would like to iterate though each feature and do a select layers by location in order to get a list of layers that each polygon intersects with.

 

Can I use a search cursor to iterate through the polygons and pass the geometry to Select Layers By Location as the select_features parameter?

 

extents = sys.argv[1]
#polygon shapefile containing 4 polygons
try:
    arcpy.env.workspace = "C:\Dataset.gdb"
    #get extents spatial reference
    ex_sp = arcpy.Describe(extents).spatialReference

    fcs = arcpy.ListFeatureClasses()
    with da.SearchCursor(extents,["SHAPE@"]) as scursor:
        for row in scursor:
            boundary = row[0]
             Output_Layer_Names, Count = arcpy.management.SelectLayerByLocation(in_layer=fcs, overlap_type="INTERSECT",
                 select_features=boundary, search_distance="", selection_type="NEW_SELECTION",
                 invert_spatial_relationship="NOT_INVERT")
            print(Output_Layer_Names,Count)
except:

 

Any help is appreciated

 

Thanks,

 

Arthur

Outcomes