#Be carefull to delete any "tmp_*" or "final_union" FCs before you run the code... otherwise those'll get unioned too import arcpy arcpy.env.workspace = r"C:\temp\python\test.gdb" fcList = arcpy.ListFeatureClasses("*", "POLYGON") i = 0 for fc in fcList: i = i + 1 if i == 1: unionFcList = [fcList[i-1],fcList] else: inputTmpFC = "tmp_" + str(i-1) unionFcList = [fcList,inputTmpFC] outTmpFC = "tmp_" + str(i) arcpy.Union_analysis(unionFcList, outTmpFC) arcpy.Delete_managment(inputTmpFC) arcpy.Rename_managment(outTmpFC, "final_union")
Hi SYM,Here's an example:import arcpy from arcpy import env env.workspace = r"C:\temp\python\test.gdb" lstFCs = arcpy.ListFeatureClasses("*", "POLYGON") arcpy.Union_analysis(lstFCs, "Union_FC")This script is creating a list of all the polygon feature classes, and then passing this list as the input for the Union GP tool.
import arcpy from arcpy import env env.workspace = r"C:\temp\python\test.gdb" lstFCs = arcpy.ListFeatureClasses("*", "POLYGON") arcpy.Union_analysis(lstFCs, "Union_FC")
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.