12

In ArcGIS Desktop, there is a tool called Create Layer from Selected Features. Using this tool, I can convert a selection to a layer in ArcMap.

It's my guess that there is a "list of features" that is embedded in the layer somewhere that isolates which features to show in the map.

I would have thought that the "list of features" would have been stored in a where clause in a definition query as a list of objectids. For example: where objectid in(123,456,789,...). However, this is not the case.

If the layer doesn't have a WHERE clause or definition query, then how is the list of features stored?

  • 2
    There is a big difference between menu item and geoprocessing tool. What you are talking is former. You can use data stored in fidset to make your layers. – FelixIP Sep 22 '17 at 19:32
  • 2
    I'm pretty sure that there is no WHERE clause stored when you create a Selection Layer and that once it's created, you can NOT find out the original selection used to create it. I hope I'm proven wrong in the form of an answer because I was dealing with a very old selection layer recently and finding out the original selection of features used to create it would have been handy. – Dan C Sep 22 '17 at 19:58
  • 1
    Fidset is property of the layer. It is ; separated string to store selection FIDs. – FelixIP Sep 22 '17 at 20:32
  • 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. This is nothing like a Query layer, which stores a where clause – jbalk Sep 25 '17 at 1:29
14

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(';'))
11
+50

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.

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.