Label | Explanation | Data Type |
Input Features | The input feature class or layer from which the new layer will be made. Complex feature classes, such as annotation and dimensions, are not valid inputs. | Feature Layer |
Output Layer | The name of the feature layer to be created. The layer can be used as input to any geoprocessing tool that accepts a feature layer as input. | Feature Layer |
Expression (Optional) | An SQL expression used to select a subset of features. If the input is a layer with an existing definition query and a where clause is specified with this parameter, both where clauses will be combined with an AND operator for the output layer. For example, if the input layer has a where clause of ID > 10 and this parameter is set to ID < 20, the resulting layer's where clause will be ID > 10 AND ID < 20. | SQL Expression |
Workspace or Feature Dataset (Optional) | Legacy:This parameter is not used. In ArcGIS Desktop, output field names are validated based on this workspace. In ArcGIS Pro, this tool does not support changing the field names because layers do not support field names that differ from the underlying data source. | Workspace; Feature Dataset |
Field Info (Optional) | The fields from the input features that will be included in the output layer. You can remove input fields by making them not visible, and you can set numeric fields to have a ratio split policy. Renaming fields is not supported. | Field Info |
Summary
Creates a feature layer from a feature class or layer file. The layer that is created is temporary and will not persist after the session ends unless the layer is saved to disk or the map document is saved.
Usage
The temporary feature layer can be saved as a layer file using the Save To Layer File tool or as a new feature class using the Copy Features tool.
Complex feature classes, such as annotation and dimensions, are not supported.
If an SQL expression is used but returns nothing, the output will be empty.
A split policy can be set using the Ratio option for the Field Info parameter. The split policy can be used when the feature layer is being used as an input to a tool, and a geometry of the input feature layer is split during processing. When the split geometry is sent to the output, a ratio of the input attribute value is calculated for the output attribute value. When the Ratio option is used, whenever a feature in an overlay operation is split, the attributes of the resulting features are a ratio of the attribute value of the input feature. The output value is based on the ratio in which the input feature geometry was divided. For example, if the input geometry was divided equally, each new feature's attribute value is assigned one-half the value of the input feature's attribute value. The split policy only applies to numeric field types.
The default is none (unchecked). This means the attribute of the two resulting features is a copy of the original object's attribute value.
Caution:
Geoprocessing tools do not support geodatabase feature class or table field split policies.
When using ModelBuilder to create a tool, ensure that the input data variable to this tool is not flagged as intermediate. If the input is flagged as intermediate, it will be deleted after the model is run and the output layer will not be added to the display.
In a model, the output variable for this tool can be assigned a layer file containing the symbology that will be applied to the layer being created. When the layer being created is returned as a model or script tool output parameter to a map, the symbology from the layer file is preserved but the label properties are not. However, if the layer created by this tool in a model is saved as permanent data (a feature class or shapefile) and that permanent data is returned to the map as an output parameter, the label properties from the layer file will be correctly applied.
If the Input Features parameter value is a layer, the input's symbology, selection, and definition query will be transferred to the output layer
Parameters
arcpy.management.MakeFeatureLayer(in_features, out_layer, {where_clause}, {workspace}, {field_info})
Name | Explanation | Data Type |
in_features | The input feature class or layer from which the new layer will be made. Complex feature classes, such as annotation and dimensions, are not valid inputs. | Feature Layer |
out_layer | The name of the feature layer to be created. The layer can be used as input to any geoprocessing tool that accepts a feature layer as input. | Feature Layer |
where_clause (Optional) | An SQL expression used to select a subset of features. For more information on SQL syntax see the help topic SQL reference for query expressions used in ArcGIS. If the input is a layer with an existing definition query and a where clause is specified with this parameter, both where clauses will be combined with an AND operator for the output layer. For example, if the input layer has a where clause of ID > 10 and this parameter is set to ID < 20, the resulting layer's where clause will be ID > 10 AND ID < 20. | SQL Expression |
workspace (Optional) | Legacy:This parameter is not used. In ArcGIS Desktop, output field names are validated based on this workspace. In ArcGIS Pro, this tool does not support changing the field names because layers do not support field names that differ from the underlying data source. | Workspace; Feature Dataset |
field_info (Optional) | The fields from the input features that will be included in the output layer. You can remove input fields by making them not visible, and you can set numeric fields to have a ratio split policy. Renaming fields is not supported. | Field Info |
Code sample
The following Python window script demonstrates how to use the MakeFeatureLayer function in immediate mode.
import arcpy
arcpy.env.workspace = "C:/data/input"
arcpy.MakeFeatureLayer_management("parcels.shp", "parcels_lyr")
The following stand-alone script demonstrates how to use the MakeFeatureLayer function to create a layer that can be used by the SelectLayerByLocation and SelectLayerByAttribute functions.
# Name: makefeaturelayer_example_2.py
# Description: Uses MakeFeatureLayer with custom field info as input to Intersect
# Import system modules
import arcpy
# Set overwrite option
arcpy.env.overwriteOutput = True
# Set data path
cityboundaries = "C:/data/City.gdb/boundaries"
countyboundaries = "C:/data/City.gdb/counties"
# Get the fields from the input
fields = arcpy.ListFields(cityboundaries)
# Create a fieldinfo object
fieldinfo = arcpy.FieldInfo()
# Iterate through the input fields and add them to fieldinfo
for field in fields:
if field.name == "POPULATION":
# Set the Population to have a ratio split policy
fieldinfo.addField(field.name, field.name, "VISIBLE", "RATIO")
else:
fieldinfo.addField(field.name, field.name, "VISIBLE", "NONE")
# Make a layer from the feature class
arcpy.management.MakeFeatureLayer(cityboundaries, "city_boundaries_lyr", fieldinfo)
# Intersect cities and counties, splitting city population proportionally by county
arcpy.analysis.Intersect([["city_boundaries_lyr"],[countyboundaries]], "memory/intersected_city_counties")