Iterate Layers (ModelBuilder)

Summary

Iterates layers in a map.

Learn how Iterate Layers works in ModelBuilder

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:
      Example of using the layer type derived output
    • 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.
      Example of using the workspace type derived output

  • 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})
ParameterExplanationData 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.

  • AnnotationLayerAnnotation layers will be iterated.
  • BuildingLayerBuilding layers will be iterated.
  • BuildingSceneLayer Building scene layers will be iterated.
  • DimensionLayerDimension layers will be iterated.
  • FeatureLayerFeature layers will be iterated.
  • GALayerGeostatistical layers will be iterated.
  • GroupLayerGroup layers will be iterated.
  • KMLLayerKML layers will be iterated.
  • LASDatasetLayerLAS dataset layers will be iterated.
  • MosaicLayerMosaic layers will be iterated.
  • NALayerNetwork Analyst layers will be iterated.
  • NetworkDatasetLayerNetwork dataset layers will be iterated.
  • ParcelLayerParcel layers will be iterated.
  • RasterLayerRaster layers will be iterated.
  • SceneServiceLayerScene service layers will be iterated.
  • TableViewTable views will be iterated.
  • TerrainLayerTerrain layers will be iterated.
  • TinLayerTIN layers will be iterated.
  • TopologyLayerTopology layers will be iterated.
  • TraceNetworkLayerTrace network layers will be iterated.
  • UtilityNetworkLayerUtility network layers will be iterated.
  • VoxelLayerVoxel layers will be iterated.
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.

  • BIG_DATA_CONNECTIONLayers in a big data connection workspace will be iterated.
  • BIM_FILELayers in a BIM File workspace will be iterated.
  • CADLayers in a CAD workspace will be iterated.
  • DELIMITED_TEXT_FILELayers in a delimited text file workspace will be iterated.
  • ENTERPRISE_GEODATABASELayers in a enterprise geodatabase workspace will be iterated.
  • FEATURE_SERVICELayers in a feature service workspace will be iterated.
  • FILE_GEODATABASELayers in a file geodatabase workspace will be iterated.
  • IN_MEMORY_DATABASELayers in an in memory database workspace will be iterated.
  • MICROSOFT_EXCELLayers in a Microsoft Excel workspace will be iterated.
  • NETCDFLayers in a NetCDF workspace will be iterated.
  • OLEDBLayers in a OLE DB workspace will be iterated.
  • RASTERLayers in a raster workspace will be iterated.
  • SHAPEFILELayers in a shapefile workspace will be iterated.
  • SQLITELayers in an SQLite workspace will be iterated.
  • SQL_QUERY_LAYERLayers in a SQL query layer workspace will be iterated.
  • STREAM_SERVICELayers in a stream service workspace will be iterated.
  • WEB_FEATURE_SERVICELayers in a web feature service workspace will be iterated.
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.

  • ANNOTATIONAnnotation feature classes will be iterated.
  • DIMENSIONDimension feature classes will be iterated.
  • SIMPLE_EDGESimple edge feature classes will be iterated.
  • COMPLEX_EDGEComplex edge feature classes will be iterated.
  • SIMPLE_JUNCTIONSimple junction feature classes will be iterated.
  • COMPLEX_JUNCTIONComplex junction feature classes will be iterated.
  • LINELine feature classes will be iterated.
  • POINTPoint feature classes will be iterated.
  • POLYGONPolygon feature classes will be iterated.
  • MULTIPATCHMultipatch feature classes 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.

  • VISIBLELayer visibility will be used to filter the layers and visible layers will be iterated.
  • NOT_VISIBLELayer visibility will not be used to filter the layers and nonvisible 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.

  • VALIDValid layers will be iterated.
  • INVALIDInvalid layers will be iterated.
String
recursive
(Optional)

Specifies whether the iterator will iterate nested group layers.

  • Checked—Nested group layers will be iterated.
  • Unchecked—Nested group layers will not be iterated.
Boolean

Derived Output

NameExplanationData 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

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes