Label | Explanation | Data Type |
Input Features | The input feature class or layer from which features will be selected. | Feature Layer |
Output Feature Class | The output feature class that will be created. If no expression is used, the output will contain all the input features. | Feature Class |
Expression (Optional) | An SQL expression used to select a subset of features. | SQL Expression |
Summary
Extracts features from an input feature class or input feature layer, typically using a select or SQL expression, and stores them in an output feature class.
Usage
The select or SQL expression is built with the Query Builder or is typed in. For details on the expression syntax, see Introduction to query expressions or SQL reference for query expressions used in ArcGIS.
If a layer is used for the Input Features parameter value and no expression is entered, only the selected features will be written to the output feature class. If a layer with a selection is used for the Input Features parameter value and an Expression parameter value is specified, the expression will only be run on the selected features, and the expression-based subset of the selected set will be written to the output feature class. If the selected features do not contain any features that match the expression, only features in the selected set will be written to the output.
If you already have a layer with a selected set of features, use the Copy Features tool to create a feature class.
Parameters
arcpy.analysis.Select(in_features, out_feature_class, {where_clause})
Name | Explanation | Data Type |
in_features | The input feature class or layer from which features will be selected. | Feature Layer |
out_feature_class | The output feature class that will be created. If no expression is used, the output will contain all the input features. | Feature Class |
where_clause (Optional) | The SQL expression that will be used to select a subset of features. For more information about SQL syntax, see SQL reference for query expressions used in ArcGIS. | SQL Expression |
Code sample
The following Python window script demonstrates how to use the Select function in immediate mode.
import arcpy
arcpy.env.workspace = "C:/data"
arcpy.analysis.Select("majorrds.shp", "C:/output/majorrdsClass4.shp", '"CLASS" = \'4\'')
The following Python script demonstrates how to use the Select function in a stand-alone script.
# Name: Select_Example2.py
# Description: Select roads of Class 4 from major roads in the gnatcatcher habitat study area
# Import system modules
import arcpy
# Set workspace
arcpy.env.workspace = "C:/data"
# Set local variables
in_features = "majorrds.shp"
out_feature_class = "C:/output/majorrdsClass4.shp"
where_clause = '"CLASS" = \'4\''
# Run Select
arcpy.analysis.Select(in_features, out_feature_class, where_clause)
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes