Make Feature Layer (Data Management)

Summary

Creates a feature layer from an input 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.

  • 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.

  • A split policy can be set using the Field Info parameter's Ratio option. The split policy comes into effect 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 Ratio 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. The 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.

    Caution:

    Geoprocessing tools do not honor 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 the 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 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 the Make Feature Layer 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

LabelExplanationData 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 newly created 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)

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.

Workspace; Feature Dataset
Field Info
(Optional)

The fields from the input that will be renamed and made visible in the output. A split policy can be specified.

Field Info

arcpy.management.MakeFeatureLayer(in_features, out_layer, {where_clause}, {workspace}, {field_info})
NameExplanationData 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 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.

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)

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.

Workspace; Feature Dataset
field_info
(Optional)

The fields from the input that will be renamed and made visible in the output. A split policy can be specified.

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 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
from arcpy import env

# 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.MakeFeatureLayer_management(cityboundaries, "city_boundaries_lyr", fieldinfo)

# Intersect cities and counties, splitting city population proportionally by county
arcpy.Intersect_analysis([["city_boundaries_lyr"],[countyboundaries]], "memory/intersected_city_counties")

Environments