I'm struggling trying to use Model Builder's iterator tool. I'm trying to use the iterator to search through 6 geodatabases and merge each feature classes with the same name (BuildP, CisternA etc.) into a single point/line/polygon file.
I was using "Iterate Feature Classes" to point to the geodatabases and the merge tool to merge the same name feature classes together. I'm not sure how to tell ArcMap to merge based on file name though.
My goal is to find a way to automate this process for the rest of my team. If my method of using Model Builder's iterator function isn't well-suited to this task, what may work better?
UPDATE: I'm not having any luck using Model Builder's Iterator function. I have a (very) slow work-around for merging geodatabases, but I'm still struggling to find a way to Merge feature classes (same geometry and schema) based on name. Can someone let me know how to accomplish a name-based Merge without using scripting? There's got to be a simple ArcToolbox tool or pre-built script that accomplishes the same thing.
-
It seems like a tough, if not nearly impossible task using model builder because you can only have one iterator in a single model. May take multiple models combined to achieve this. Have you tried embedding models?MoreMeowbell– MoreMeowbell2022年04月28日 19:09:10 +00:00Commented Apr 28, 2022 at 19:09
-
that's good to know that model builder only allows a single iteration function per model. I'm not familiar with embedding models. That's something I'm gonna have to lookup. I wish I could follow up your comment with an intelligent question, but my experience level isn't adequate here.user204335– user2043352022年04月28日 21:13:25 +00:00Commented Apr 28, 2022 at 21:13
-
If you save a specific (inner) model you can save it. Then you can call it (add it) into the "wrapper" model. Not sure if that makes sense.MoreMeowbell– MoreMeowbell2022年04月28日 21:20:52 +00:00Commented Apr 28, 2022 at 21:20
-
Yep, that makes sense to me. I think I'm gonna have to experiment with model builder to get this right. So I'm just curious, do you know if there's a tool in Arc Toolbox that might have a similar function? I was thinking of using Dissolve, Merge and Append. But I'm not sure these tools were made with this functionality in mind. It's just a bit ironic how easy it is to clip, extract, export, modify and delete (etc.) geodatabases, but just how difficult it is to merge them together.user204335– user2043352022年04月28日 21:41:38 +00:00Commented Apr 28, 2022 at 21:41
-
If you're looking for an "out of the box" tool then I would suggest Append. You can append each matching feature class to one single feature class. You would have to do this for each individual feature class schema, but it's a workaround.MoreMeowbell– MoreMeowbell2022年04月29日 02:27:45 +00:00Commented Apr 29, 2022 at 2:27
1 Answer 1
Can't give you an answer based on Model Builder but you could do something like this in Python.
This script assumes all gdbs that have feature classes to be merged exist in the same folder (input_folder_of_gdbs). The other argument, out_gdb, should be the path to a gdb that you want to output the merged feature classes.
import os
import arcpy
def combine_fc_gdb(input_folder, out_gdb):
all_fcs = {}
input_gdbs = [g for g in os.listdir(input_folder) if g.upper().endswith('.GDB')]
for gdb in input_gdbs:
gdb_path = os.path.join(input_folder, gdb)
arcpy.env.workspace = gdb_path
fcs = arcpy.ListFeatureClasses()
for fc in fcs: # add to dictionary based on fc name: [fc paths]
fc_path = os.path.join(gdb_path, fc)
if fc not in all_fcs:
all_fcs[fc] = [fc_path]
else:
all_fcs[fc].append(fc_path)
for fc in all_fcs: # loop through dictionary and merge them
out_fc = os.path.join(out_gdb, fc)
print '\nMerging: {}\n{}'.format(fc, '\n'.join(all_fcs[fc]))
arcpy.Merge_management(all_fcs[fc], out_fc)
input_folder_of_gdbs = r'path/to/folder/containing/gdbs'
out_gdb = r'path/to/output.gdb'
combine_fc_gdb(input_folder_of_gdbs, out_gdb)
-
Thank you for the reply. However, I'm really not good at using Python yet so I was hoping to use Model Builder or another prebuilt tool/script to accomplish my task.user204335– user2043352022年04月22日 00:33:32 +00:00Commented Apr 22, 2022 at 0:33