Summary
Creates a feature layer from an input feature class or layer file. The layer that is created by the tool 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 can be saved as a new feature class using the Copy Features tool.
Complex feature classes, such as annotation and dimensions, are not supported by this tool.
-
Layers created in ArcCatalog cannot be used in ArcMap unless they are saved to a layer file using the Save To Layer File tool.
If an SQL expression is used but returns nothing, the output will be empty.
Field names can be given a new name by using the Field Info control. The second column on the control lists the existing field names from the input. To rename a field, click the field name and type in a new one.
New field names defined in the Field Info control will be honored in subsequent tools. However, if this tool is the last tool in a model, the field names will be obtained from the source data on disk. To maintain new field names, the new layer has to be written out to a new data using Copy Rows or Copy Features tools.
The field names will be validated by specifying an input workspace. Thus, if the input is a geodatabase feature class, and the output workspace is a folder, the field names may be truncated, since shapefile attributes can only have names of ten characters or less. The new names may be reviewed and altered using the Field Info control.
A subset of fields can be made unavailable in the new layer by using the Field Info control's visible property. The third column in the control provides a dropdown option to specify whether a field will be visible or hidden in the new layer. The default is TRUE. Selecting FALSE will hide that field. You cannot use the hidden fields in a workflow if the newly created layer is input to a subsequent process or tool. If the output is saved to disk, only the fields listed as visible will appear in the new data.
A split policy can be set by using the Field Info control Use Ratio Policy option. The split policy comes into effect any time 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 Use Ratio Policy is enabled, 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 of the value of the input feature's attribute value. Use Ratio Policy only applies to numeric field types.
The default is NONE (unchecked). This means the attribute of the two resulting features takes on a copy of the original object's attribute value.
When using ModelBuilder to create a tool, you need to 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 from its dialog and the output layer will not be added to the display.
In a model, the output variable of Make Feature Layer tool can be assigned a layer file from which to apply symbology to the layer being created. When the layer being created is returned as a model 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 Make Feature Layer (in a model) is saved as permanent data (feature class or shapefile), and that permanent data is returned to the map as an output parameter, the label properties from the layer file are correctly applied.
The pattern for entering a source feature class for this tool is to include all levels of data structure down to the feature class, such as C:\my.gdb\feature_dataset\feature_class_name. However, in the case of a parcel fabric, there is an extra level (the fabric structure), which you do not need to use it in the input to this tool. For example, if the catalog path to a parcel is C:\my.gdb\feature_dataset\fabric_str\feature_class_name then omit fabric_str from the path.
Syntax
MakeFeatureLayer_management (in_features, out_layer, {where_clause}, {workspace}, {field_info})
Parameter | Explanation | Data Type |
in_features | The input feature class or layer from which to make the new layer. Complex feature classes, such as annotation and dimensions, are not valid inputs to this tool. | Feature Layer |
out_layer | The name of the feature layer to be created. The newly created 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. | SQL Expression |
workspace (Optional) | The input workspace used to validate the field names. If the input is a geodatabase table and the output workspace is a dBASE table, the field names may be truncated, since dBASE fields can only have names of ten characters or less. The new names may be reviewed and altered using the field information control. | Workspace;Feature Dataset |
field_info (Optional) | Can be used to review and alter the field names and hide a subset of fields in the output layer. A split policy can be specified. See the usages for more information. | Field Info |
Code sample
MakeFeatureLayer Example 1 (Python Window)
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")
MakeFeatureLayer example 2 (stand-alone script)
The following stand-alone script demonstrates how to use MakeFeatureLayer to create a layer that can be used by SelectLayerByLocation and SelectLayerByAttribute tools.
# Name: ExtractFeaturesByLocationAndAttribute.py
# Description: Extracts features to a new feature class based on a location and an attribute query.
# Import system modules
import arcpy
# Set overwrite option
arcpy.env.overwriteOutput = True
# Put in error trapping in case an error occurs when running tool
try:
# Make a layer from the feature class
arcpy.MakeFeatureLayer_management("C:/data/mexico.gdb/cities","cities_lyr")
# Select all cities that overlap the chihuahua polygon
arcpy.SelectLayerByLocation_management("cities_lyr", "INTERSECT", "c:/data/mexico.gdb/chihuahua", "", "NEW_SELECTION")
# Within the selection (done above) further select only those cities that have a population >10,000
arcpy.SelectLayerByAttribute_management("cities_lyr", "SUBSET_SELECTION", "POPULATION > 10000")
# Write the selected features to a new featureclass
arcpy.CopyFeatures_management("cities_lyr", "c:/data/mexico.gdb/chihuahua_10000plus")
except:
print(arcpy.GetMessages())
Environments
Licensing information
- ArcGIS Desktop Basic: Yes
- ArcGIS Desktop Standard: Yes
- ArcGIS Desktop Advanced: Yes