Usage
This tool is intended for use in ModelBuilder, not in Python scripting.
When the Layer Type parameter is set to Table View, only stand-alone tables are iterated. To work with feature or raster tables, set the Layer Type parameter to Feature Layer or Raster Layer, respectively.
For each iteration, the tool returns the following outputs:
- Output Layer—The layer from the map based on the parameter filters that have been set. This layer will include any selections or joins already set on the layer.
- Name—The name of the layer. The name can be used in inline variable substitution.
- Output Layer Type—The type of layer. This value matches the layer types set with the Layer Type parameter. The output values are constants and are not localized. If two or more layer types are used, the type can be used to branch a model as shown below:
- Workspace or Format Type—The workspace type of the layer. This value is only returned for feature layers, raster layers, and table views. The output values are constants and are not localized. For raster layers that are stored in the folder-based workspace, the file format is returned—for example TIFF—and this value can be used to branch a model or as a diagnostic to evaluate the layer type that was iterated.
The tool returns layers that match the type set with the Layer Type parameter and the filters set with the Visibility and State parameters. For example, if the Layer Type parameter is set to Feature Layer and Raster Layer, the Visibilty parameter to Not Visible, and the State parameter to Valid, the tool will return feature and raster layers that are both not visible and valid.
If the Layer Type parameter is not set or there are no layers that match the parameter criteria, the value of the Output Layer is set to OUTPUT_LAYER, the value of the Name, and the Output Layer Type outputs are set to FEATURE_LAYER, and the Workspace or Format Type output is set to WORKSPACE.
The Layer Type parameter can be set to multiple types, for example Feature Layer, Raster Layer, and Table View. However, the tool can be connected to downstream tools such as Copy Features, Copy Raster, or Copy Rows that may be incompatible with some of the layer types. To support multiple layer types in this scenario, the Layer Type parameter must be set to a single specific layer type. Then connect the output to the corresponding tool that works with that specific data type. Once all the downstream connections are made, you can set the Layer Type parameter to all three layer types. This workflow is necessary because the starting default for the tool is set to a feature layer type that is not compatible with the tools that take raster as input. Once all layer types are added the model, validation leaves the tools in their valid state.
Syntax
arcpy.mb.IterateLayers(input_map, {wildcard}, {layer_type}, workspace_type, {feature_type}, {raster_format_type}, {layer_visibility}, {layer_state}, {recursive})
Parameter | Explanation | Data Type |
input_map | The input map with the layers to iterate. | Map |
wildcard (Optional) | A combination of * and characters that help to limit the results. The asterisk is the same as saying ALL. If no wildcard is specified, all inputs will be returned. For example, it can be used to restrict Iteration over input names starting with a certain character or word (for example, A* or Ari* or Land* and so on). | String |
layer_type [layer_type,...] (Optional) | Specifies the layer type used to filter the layers. If a layer type is not specified, all supported layer types will be iterated. More than one layer type can be used to filter the layers.
| String |
workspace_type [workspace_type,...] | Specifies the workspace type used to filter the layers. If a workspace type is not specified, all layers of the supported workspace types will be iterated. The Workspace Type parameter is only enabled when the Layer Type parameter is set to Feature Layer, Raster Layer, or Table View.
| String |
feature_type [feature_type,...] (Optional) | Specifies the feature type used to filter the layers. If a feature type is not specified, all supported feature types will be iterated.
| String |
raster_format_type [raster_format_type,...] (Optional) | The raster format type used to filter the raster layers when the Workspace Type parameter is set to Raster. If a raster type is not specified, all layers of the supported raster types will be iterated. | String |
layer_visibility (Optional) | Specifies whether layer visibility is used to filter the layers. If layer visibility is not specified, all layers will be iterated.
| String |
layer_state (Optional) | Specifies the layer state that will be used to filter the layers. Layers with broken source path layers are returned if the parameter is set to invalid. If a layer state is not specified, all layers will be iterated.
| String |
recursive (Optional) | Specifies whether the iterator will iterate nested group layers.
| Boolean |
Derived Output
Name | Explanation | Data Type |
output_layer | The layer from the map based on the parameter filters that have been set. This layer will include any selections or joins already set on the layer. | Any Value |
output_name | The name of the layer. | String |
output_layer_type | The type of layer. | String |
output_workspace_type | The workspace type of the layer. | String |
Environments
Licensing information
- Basic: Yes
- Standard: Yes
- Advanced: Yes