I would like to feed a list of feature classes (only one polygon per feature class, but up to 150 feature classes) into the Union tool in ModelBuilder by using a Feature Class Iterator and the Collect Values Tool.
Unfortunately, it does not work since "Collect Values" only works with Merge, Append, etc.
Does anyone know a workaround or another way to do this?
1 Answer 1
You can do this by writing a python script that inserts a list of feature classes into the union tool.
To use this method:
- In Catalog create a toolbox
- Create a Script tool
- Make the input parameter Features Class that accepts multiple values
- Copy the code below to a text document
- Save the text document and change the extension from .txt to .py
- Reference the .py file within the Script tool
Run the Script tool
import arcpy myList = arcpy.GetParameterAsText(0).split(";") unionResult = "C:\\temp\\union.shp" # make sure you have this directory C:\\temp arcpy.Union_analysis(myList, unionResult, "ALL", "", "GAPS")
Explore related questions
See similar questions with these tags.