Make Feature Layer (Data Management) |
|
Release 9.3
Last modified March 8, 2012 |
Print all topics in : "Tools" |
NOTE: This topic was updated for 9.3.1.
The Make Feature Layer tool is used to create 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 document is saved.
Learn more about working with layers.
Usage tips
Complex feature classes, such as annotation and dimensions, are not supported by this tool.
The feature layer can be used as input to any geoprocessing tool that accepts a feature class as input.
The temporary feature layer can be saved as a layer file using the Save To Layer File tool or saved as a new feature class using the Copy Features 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.
An existing feature layer will be overwritten if the same layer name is specified and if you explicitly state that overwriting outputs is allowed.
You can set this option in any application by opening the Tools menu > Options dialog box. On the Geoprocessing tab under the General heading, you'll see a check box for Overwrite the outputs of geoprocessing operations.
Learn more about overwriting geoprocessing tool results.
In a script, you will need to set the Overwrite Output method to True.
If a SQL expression is used but returns nothing, the output feature layer will be empty.
For further details on the syntax for the Expression parameter, see Building a SQL Expression or SQL Reference.
Field names can be given a new name by using the Field Information 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.
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 Information control.
A subset of fields can be made visible in the new layer by using the Field Information control. The third column in the control provides a drop-down option to specify if a field will be visible or hidden in the new layer. The default is TRUE. Selecting FALSE will hide that field. If the feature layer is saved as a new feature class, only the fields listed as visible will appear in the new output.
New field names defined in Make Feature Layer will be honored in subsequent tools. However, if Make Feature Layer is the last tool in a model, the field names will be obtained from the source feature class on disk. To maintain new field names, the new feature layer has to be written to a new feature class using Copy Features or Feature Class to Feature Class.
A split policy can be set by using the Field Information control. The fourth column on the control provides a drop-down option to specify a split policy. The default is NONE. This means the attribute of the two resulting features takes on a copy of the original object's attribute value. Selecting RATIO means the attributes of the resulting features are a ratio of the original feature's value. The ratio is based on the ratio in which the original geometry is divided. If the geometry is divided equally, each new feature's attribute gets one-half the value of the original object's attribute.
No environment settings affect this tool.
Command line syntax
An overview of the Command Line window
MakeFeatureLayer_management <in_features> <out_layer> {where_clause} {workspace} {field_info}
Parameter | Explanation | Data Type |
<in_features> |
The input feature class or 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. |
Feature Layer |
{where_clause} |
A SQL expression used to select a subset of features. The syntax for the expression differs slightly depending on the data source. For example, if you're querying file or ArcSDE geodatabases, shapefiles, or coverages, enclose field names in double quotes: "MY_FIELD" If you're querying personal geodatabases, enclose fields in square brackets: [MY_FIELD] For more information on SQL syntax and how it differs between data sources, see SQL Reference. |
SQL Expression |
{workspace} |
The input workspace used to validate the field names. 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 Information control. |
Workspace | Feature Dataset |
{field_info} |
The Field Information control is used to review and alter the field names for the new layer. Fields can be hidden, and a split policy can be specified. |
Field Info |
MakeFeatureLayer_management D:\Workspace.mdb\Transport 'Major Roads' '[ROADCODE] = "4"' "D:/Workspace" "LEVEL ROAD_CLASS VISIBLE, LENGTH LENGTH VISIBLE RATIO"
Scripting syntax
About getting started with writing geoprocessing scripts
MakeFeatureLayer_management (in_features, out_layer, where_clause, workspace, field_info)
Parameter | Explanation | Data Type |
in_features (Required) |
The input feature class or layer. Complex feature classes, such as annotation and dimensions, are not valid inputs to this tool. |
Feature Layer |
out_layer (Required) |
The name of the feature layer to be created. |
Feature Layer |
where_clause (Optional) |
A SQL expression used to select a subset of features. The syntax for the expression differs slightly depending on the data source. For example, if you're querying file or ArcSDE geodatabases, shapefiles, or coverages, enclose field names in double quotes: "MY_FIELD" If you're querying personal geodatabases, enclose fields in square brackets: [MY_FIELD] For more information on SQL syntax and how it differs between data sources, see SQL Reference. |
SQL Expression |
workspace (Optional) |
The input workspace used to validate the field names. 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 Information control. |
Workspace | Feature Dataset |
field_info (Optional) |
The Field Information control is used to review and alter the field names for the new layer. Fields can be hidden, and a split policy can be specified. |
Field Info |
# ExtractFeaturesByLocationAndAttribute.py # Description: Extract features to a new feature class based on a Location and an attribute query # Requirements: Python and the Python win32all extension # Author: ESRI # Data 1/1/2004 # Create the Geoprocessor import arcgisscripting gp = arcgisscripting.create() # Put in error trapping in case an error occurs when running tool try: # Make a layer from the feature class gp.MakeFeatureLayer("c:/mexico.mdb/cities","lyr") # Select all cities that overlap the chihuahua polygon gp.SelectLayerByLocation("lyr", "intersect", "c:/mexico.mdb/chihuahua", 0, "new_selection") # Within the selection (done above) further select only those cities that have a population >10,000 gp.SelectLayerByAttribute("lyr", " [population] > 10000 ", "SUBSET_SELECTION") # Write the selected features to a new featureclass gp.CopyFeatures("lyr", "c:/mexico.mdb/chihuahua_10000plus") except: # If an error occurred print the message to the screen print gp.GetMessages()