Select to view content in your preferred language

Modelbuilder Merging many features based on like filename grouping

254
1
06-18-2018 10:29 AM
BrianWade
Occasional Contributor

Hi All

 

I'm looking for what I believe is a very simple process, but my brain block is getting in the way of my solution.

 

I would like to merge counties from a gdb filled with 2015 US Census County features into individual State features based on the State fips field within each county feature, i.e. 01,02,04 etc. into individual state features 01_counties, 02_counties etc.

 

I realize I can do this 54 times using geoprocessing tools, but I would like to do this in model builder so as to be able to use this process tool for future use with different variables.

 

I assume I can Iterate through the gdb to parse out or group by filename state fips and merge into new state files.

each feature has a st fips as part of its filename i.e.

 

tl_2015_60010_counties, tl_2015_60010_counties, tl_2015_60010_counties

tl_2015_69085_counties, tl_2015_69100_counties, tl_2015_69110_counties, tl_2015_69120_counties

tl_2015_78010_counties, tl_2015_78020_counties, tl_2015_78030_counties

 

into state features:

 

tl_2015_60_counties

tl_2015_69_counties

tl_2015_78_counties

 

Ultimately, I’m looking to merge files based on a like portion of the filename via model builder.

I’m sure it’s right in front of me but its Monday so I’m temporarily blind!

 

I understand Iteration tools, but the maybe collect values? I don’t understand if that fits into my question or not.

 

Thanks for any help

 

Brian.

0 Kudos
1 Reply
curtvprice
MVP Esteemed Contributor

Have you tried creating a submodel that does Iterate Feature Classes (on a wildcard) followed by Collect Values, passed to the Merge tool in your main model? The main model could generate the wildcard (even with an iterator) and pass the wildcard as a parameter to the submodel, with the submodel passing the list of feature classes to merge back.

If You Are Stuck At If‌ blog series is a really good reference on advanced ModelBuilder topics.