2

I'm trying to merge feature classes, that come from a submodel ("PFA_findBiggest") via inline variable substitution. They are saved in a GDB.

enter image description here

They all have different fields. I want to merge them into one big table according to a fishnet_FID, that they all carry.

Here you can see, I tried the merge function in order to merge them into a feature class, but this didn't work. It only ever 'merged' the first %n%, which of course is 0, and nothing else. So the output of Merge is identical to the first layer processed.

I guess it's because Merge doesn't know that more is coming. That's why I have put the "Collect Values"-Tool in between. It is set to the the output of the submodel, including the %n%.

enter image description here Why is this not working?


I got it to work by placing the "Collect Values" Tool inside the submodel, as described. But it seems merge is not the right tool yet. It only adds the rows of each feature class together.

How do I use the FID that all feature classes have, to connect the data?

I tried Join Field instead of Merge, but ModelBuilder only lets me connect the output of Collect Values to Join Field as Precondition.

Or maybe there is a tool, that I can use after merge, to shrink the table according to the FID?

3

The Collect Values tool should be in the sub model and exposed as a parameter. It should not be in the master model as you have it. Your sub-model should be passing out a LIST of FeatureClasses to feed into the merge tool.

As I read your current model logic, the sub-model will be iterating but the final output is overwritten and when it finally comes out of the sub-model it is passing the last featureclass into the collects tool which is then feeding a list of 1 featureclass into the merge tool, which makes no sense.

  • Ok I got it to work by placing the "Collect Values" Tool inside the submodel, as you described. But it seems merge is not the right tool yet. It only adds the rows of each feature class together. How do I use the FID that all feature classes have, to connect the data? I tried Join Field instead of Merge, but Model Builder only lets me connect the output of Collect Values to Join Field as Precondition. Or maybe there is a tool, that I can use after merge, to shrink the table according to the FID? – kett Feb 10 '17 at 13:23
  • Is your FID just a normal order number or is something special? If is a normal order number you can add field with it before looping and then loop through your feature using this field – Losbaltica Feb 11 '17 at 5:42
  • It's a normal order number. I now started converting my model builder model into python code. I hope I'll then have a better chance to deal with this. model builder is just too frustrating. – kett Feb 15 '17 at 8:59
2

You need to create 2 separate models. One that iterate through feature (loop) and another which will call sub-model. Also i recommend to create outside database when you use iterators otherwise you will have lots of temp features in your main database.

Your sub-model should look something like that:

Sub model

And them you just simple call it.

Main

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.