I am trying to iterate a series of feature classes (polygons) from two different/separated folders in model builder to convert a series of polygons using union and then the output for aggregate polygon tool. However, I am having an issue with the input file names. I have to match each entry with part of their names which are sharing a map#. In example both files are sharing map number like orange001 and apple001 or onion002 and banana002. I need help on matching the name of each file entry and reading it as input for my model to create a desire output. I used 2 models as subtype and type which I can use the subtype and read the 1st file from my first folder and then I have to match its name with 2nd entry and grab the shp file and continue my work.
Here are some general steps to do this via python/arcpy:
- Use my answer in this Q/A (see link below) for understanding how to find like name feature classes. For your case the logic will be slightly different since you will need to walk through two different directories. You will need to nest one walk statement/loop within the first walk statement/loop (one looking at the one dir and the other looking in the other dir).
- After you have the two found layers assigned to different variables, insert those into the Union method (link has a arcpy code sample). Since this is geoprocessing tool, I would suggest to use in-memory workspace for the union layers
- Finally, reference the output union layer into the Aggregate method (link has a arcpy code sample)