byoungs32

Select by Attributes Using Python List

Discussion created by byoungs32 on Sep 8, 2011
Latest reply on Apr 10, 2012 by l_sulews
All,

Is there an efficient way to select multiple features in a feature class using a Python list containing OIDs of the features?

What I have set up right now is the following:

for OID in OIDlist:
     query = 'OID = ' + OID
     gp.SelectByAttribute(layername, "ADD_TO_SELECTION", query)

That works, however it is painfully slow. Is there another approach that I can use (possibly avoiding the GP SelectByAttributes tool?) that would be more efficient?

My desired end result is a layer file that only contains the features with OIDs specified in the list.

Thanks in advance.

Outcomes