Create Layer from Selected Features tool: How is the list of features stored?

Create Layer From Selected Features DOES NOT create a DYNAMIC layer. The resulting layer is not dynamic at all. It is based on an FIDset.

If you change the source data, the FIDs will change and your selection layer will break.

There is no where clause in a selection layer. It is based on FIDset (the FIDs that were selected when you used 'Create layer from selected features').

Please note that if you add or remove records from the source data, the FIDs will change, and your selection layer will show incorrect records.

You are confusing the selection layer with a query layer, which stores a where clause and is dynamic.

EDIT: The list of features for a selection layer is stored in memory. It is bad practice to use selection layers other than for temporary work as there is no way to recover the original selection once the selection layer breaks.

To find the list of features in a selection layer, you can use many different methods including SearchCursor to build a list of IDs.

Something like this:

OIDlist = []
with arcpy.da.SearchCursor(layer, 'OBJECTID') as scur:
    for row in scur:
        OIDlist.append(row[0])

From comment by crmackey:

There is also a built-in way with describe to get the FIDSet. This is a string, but is easy to convert to a list:

OIDlist = map(int, arcpy.Describe(layer).FIDSet.split(';'))

The best way I've understood how Create Layer from Selected Featuresis this reference that I came across Create a temporary layer to select features

Creating a temporary layer allows you to do things, such as make selections, without affecting the original data source. This layer will not appear in the ArcCatalog contents, because it is created in-memory and simply references the data stored on disk. These layers can be used as inputs to other geoprocessing tools within your working session. Once you exit the application the in-memory layers will be removed.

The Make Feature Layer tool is in the Layers and Table Views toolset, within the Data Management Tools toolbox. Right-click the Make Feature Layer tool and click Open, or double-click it to open the tool.

The mechanism that can read into that disk space would be how to access the "set of results"

Also, as mentioned previously and Esri cover it Working with selected features,

In this example, the layer that is created from selected features is only useful as a temporary working dataset (for example, for use as input into a geoprocessing model). The new layer makes a list of the FeatureIDs (FIDs) or ObjectIDs (OIDs) of the selected features and will become invalid when the original data source is updated or changed.

Also, here is more discussion as a general reading,Using in-memory workspace, related to in_memory workspace. This is just intended for additional information if you were interested.


My guess is that, the layer from Create Layer From Selected Features isn't based on a WHERE clause or a logical condition, because the selection set can be created without involving logic.

For example, you can manually add/delete any features from the selection set using the main menu by e.g. dragging a box, which may be from one of the previous Select by Attributes/Location.

My guess is that the selection set (IFeatureSelection) is just an extensive set of results (containing copies of the IDs of the original layer), rather than the rules defining the result set. Hence the warning in the linked documentation that the ID's may become invalid if the IDs of the original layer changes.