# Import arcpy module import arcpy, sys, traceback arcpy.env.overwriteOutput = True from os import path as p # Set Workspace arcpy.env.workspace = r"G:\ChrisGIS\PS_Steelhead\Archive" # Set Variables. "out" will be our output variable. Inside the "Try" loop we search all workspaces # for the Feature Class we are interested in. This list of feature classes is set to listFCS out = r"G:\ChrisGIS\PS_Steelhead\Scratch" for ws in arcpy.Listworkspaces("*", "FileGDB"): arcpy.env.workspace = ws print '\n\Searching in %s\n\n' %ws listFCS = arcpy.ListFeatureClasses("*_NWIFC_STHD") # Now Merge all Feature Classes and export to the Output arcpy.Merge_management(listFCS, os.path.join(out, "Merged_HUC8_STHD") print "Done"
Solved! Go to Solution.
import arcpy, sys, os, traceback arcpy.env.overwriteOutput = 1 # Set Workspace arcpy.env.workspace = r"G:\ChrisGIS\PS_Steelhead\Archive" # Set Variables. "out" will be our output variable. Inside the "Try" loop we search all workspaces # for the Feature Class we are interested in. This list of feature classes is set to listFCS out = r"G:\ChrisGIS\PS_Steelhead\Scratch\Scratch.gdb" # list for all feature classes from different GDBs to merge fcToMerge = [] for ws in arcpy.ListWorkspaces("*", "FileGDB"): arcpy.env.workspace = ws print '\n\Searching in %s\n\n' %ws listFCS = arcpy.ListFeatureClasses("*_NWIFC_STHD") # create a list with full pathes to feature classes listFCsFullPath =[] for fc in listFCS: listFCsFullPath.append(os.path.join(ws, fc)) fcToMerge += listFCsFullPath # Now Merge all Feature Classes and export to the Output arcpy.Merge_management(fcToMerge, os.path.join(out, "Merged_HUC8_STHD")) print "Done"
import arcpy, sys, os, traceback arcpy.env.overwriteOutput = 1 # Set Workspace arcpy.env.workspace = r"G:\ChrisGIS\PS_Steelhead\Archive" # Set Variables. "out" will be our output variable. Inside the "Try" loop we search all workspaces # for the Feature Class we are interested in. This list of feature classes is set to listFCS out = r"G:\ChrisGIS\PS_Steelhead\Scratch\Scratch.gdb" # list for all feature classes from different GDBs to merge fcToMerge = [] for ws in arcpy.ListWorkspaces("*", "FileGDB"): arcpy.env.workspace = ws print '\n\Searching in %s\n\n' %ws listFCS = arcpy.ListFeatureClasses("*_NWIFC_STHD") # create a list with full pathes to feature classes listFCsFullPath =[] for fc in listFCS: listFCsFullPath.append(os.path.join(ws, fc)) fcToMerge += listFCsFullPath # Now Merge all Feature Classes and export to the Output arcpy.Merge_management(fcToMerge, os.path.join(out, "Merged_HUC8_STHD")) print "Done"
import arcpy, sys, os, traceback arcpy.env.overwriteOutput = 1 # Set Workspace arcpy.env.workspace = r"G:\ChrisGIS\PS_Steelhead\Archive" # Set Variables. "out" will be our output variable. Inside the "Try" loop we search all workspaces # for the Feature Class we are interested in. This list of feature classes is set to listFCS out = r"G:\ChrisGIS\PS_Steelhead\Scratch\Scratch.gdb" # list for all feature classes from different GDBs to merge fcToMerge = [] for ws in arcpy.ListWorkspaces("*", "FileGDB"): arcpy.env.workspace = ws print '\n\Searching in %s\n\n' %ws for fd in arcpy.ListDatasets("*", "Feature") arcpy.env.workspace = fd print '\n\Searching in %s\n\n' %fd listFCS = arcpy.ListFeatureClasses("*_NWIFC_STHD") # create a list with full pathes to feature classes listFCsFullPath =[] for fc in listFCS: listFCsFullPath.append(os.path.join(ws, fc)) fcToMerge += listFCsFullPath # Now Merge all Feature Classes and export to the Output arcpy.Merge_management(fcToMerge, os.path.join(out, "Merged_HUC8_STHD"))