Skip To Content

Examples of using logical tools in ModelBuilder

If Data Exists

The following example uses If Data Exists in ModelBuilder to check if the input features coming from a model parameter exist on disk. The If Data Exists logical tool has two Boolean outputs: True and False. If the input exists, then the True output variable and the precondition are set to true thus allowing the Calculate Field tool to run. If the False output variable is true (meaning the data does not exist), then the model makes a copy of another dataset and runs the Calculate Field tool using this alternate dataset as input.

If Data Exists in ModelBuilder

If Field Exists

The following example uses If Field Exists in ModelBuilder to check if fields of a given name already exist in a dataset. The If Field Exists logical tool has two Boolean outputs: True and False. If the field does not exist in the input dataset, then the False output variable and precondition are set to true thus allowing the Add Field tool to run. If the True output variable is true (meaning the field does exist), then the model ends as no tools are connected to the True branch.

If Field Exists in ModelBuilder

If Selection Exists

The following example uses If Selection Exists in ModelBuilder to check if the input has any selected features and the number of selected features. If Selection Exists is used after first running Selection Layer By Attribute. The If Selection Exists logical tool has two Boolean outputs: True and False. If the input has any selected features, then the True output variable and the precondition are set to true thus allowing the Summary Statistic tool to run. If the False output variable is true (meaning no features are selected), then the model ends as no tools are connected to the False branch.

If Selection Exists in ModelBuilder

If Coordinate System Is

The following example uses If Coordinate System Is in ModelBuilder to check if a dataset has a certain coordinate system. The If Coordinate System Is logical tool has two Boolean outputs: True and False. This model iterates over feature classes in a geodatabase and checks if each feature class has a particular projected coordinate system. If each feature class does not have a specified coordinate system, the False output variable and the precondition are set to true thus allowing the Project tool to run. If the True output variable is true (meaning the input dataset has the specified coordinate system), then the model ends because no tools are connected to the True branch.

If Coordinate System Is in ModelBuilder

If Data Type Is

The following example uses If Data Type Is in ModelBuilder to check the data type of the input dataset. The If Data Type Is logical tool has two Boolean outputs: True and False. This model checks if the input data model parameter is a shapefile or feature class, then processes the data accordingly. If the input data is a shapefile, the True output variable and the precondition are set to true thus allowing the bottom branch of multiple Add Field and Calculate Field tools to run. If the False output variable is true (meaning the input data is not a shapefile), then the model runs the top branch.

If Data Type Is in ModelBuilder

If Feature Type Is

The following example uses If Feature Type Is in ModelBuilder to check if a specific dataset is a point feature class. The Adds Locations tool only accepts points as input, so if points are not provided as input to the model, the input features can first be converted to points. The If Feature Type Is logical tool has two Boolean outputs: True and False. If the input features are polygons or lines, the True output variable and the precondition are set to true thus allowing the Feature to Point tool to run and convert the features to points. If the False output variable is true (meaning the input features are not polygons or lines), then the model uses the input features as-is without first converting them to points.

This model also uses the Merge Branch logical tool to merge both the True and False branches so that the same chain of tools can be run on either branch.

If Feature Type Is in ModelBuilder

If Field Value Is

The following example uses If Field Value Is in ModelBuilder to check if the input data has a particular value in an attribute field. The If Field Value Is logical tool has two Boolean outputs: True and False. If the specified field has the test value, the True output variable and the precondition are set to true thus allowing the Apply Symbology from Layer tool to run. If the test value does not exist in the attribute field, the False output variable is true and the Add Join tool executes before applying the symbology.

If Field Value Is in ModelBuilder

If Row Count Is

The following example uses If Row Count Is in ModelBuilder to check the number of records in the input dataset. The If Row Count Is logical tool has two Boolean outputs: True and False. If the input dataset has more than one feature, the True output variable and the precondition are set to true thus allowing the Dissolve tool to run. If the input dataset does not have more than one feature, the False output variable is true and the tools in the bottom branch are run.

If Row Count Is in ModelBuilder

If Spatial Relationship Is

The following example uses If Spatial Relationship Is in ModelBuilder to check if a layer has features with a spatial relationship with another layer's features. The If Spatial Relationship Is logical tool has two Boolean outputs: True and False. In this example, if any of the crime data intersects the school district, then the True output variable and the precondition are set to true thus allowing the Make Feature Layer and Select Layer by Location tools to run. If the False output variable is true (meaning no input features have the specified spatial relationship with the selecting features), then the model ends as no tools are connected to the False branch.

If Spatial Relationship Is in ModelBuilder