These videos review the requirements and syntax to perform feature or record selections, such as the MakeFeatureLayer routine, SelectLayerByAttribute, and SelectLayerByLocation. The CopyFeatures and CopyRows routines are used to write out (save) feature classes or data tables to disk.
See the Ch 5 Demo Scripts, Data, and Jupyter Notebooks zip file to review and practice the concepts shown in these videos. This section corresponds to the Chapter 5 content in the Python Primer for ArcGIS Workbook (vol 2).
Query Example in Pro
This short video shows how a definition query is performed in Pro. A “query” statement can be added as a parameter in the MakeFeatureLayer routine which acts like a “definition query.” The same query structure can be used in the query parameter (aka where clause) in the SelectLayerByAttribute routine.
Make Feature Layer
This video reviews the MakeFeatureLayer routine with and without the query parameter. The print statements show that the feature count changes. Code developers need to be aware of this since the coder may or may not want the query parameter entered as part of the MakeFeatureLayer, but it may be more appropriate to use the query parameter in the SelectLayerByAttribute routine.
Select Layer by Attribute and by Location
This video puts the MakeFeatureLayer, query, and the SelectLayerByAttribute and SelectLayerByLocation together into a single script. The resulting feature selections use the CopyFeatures and CopyRows routines to write out (save) to a feature class and attribute table.