Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

My model requires field1 to be added to fc1 and fc2, and then calculated according to a Python expression calc1. field2 is then added to fc2, and calculated using calc1. How do I add the multiple feature classes as the input to Add Field and Calculate Field? I have tried creating an input table variable as a list of values, and while it accepts fc1 and fc2 when I type it in, the model does not run ("dataset does not exist").

edit I'm adding these fields so that I can join the tables on a common pre-existing field and populate fc2.field1 with the values from fc1.field1.

model screenshot

share|improve this question
    
Can you add a picture of your model please? It is perfectly possible to add a list of feature classes to the functions you describe, so I think something else is going on. –  MappaGnosis May 15 '12 at 10:00
1  
Iterators or Python loops are a must for repetative tasks (I prefer the programming method for reusablility with other projects). –  Roy May 15 '12 at 11:22
    
@SylvesterSneekly I've added an image. –  Cindy Williams May 15 '12 at 12:42

2 Answers 2

up vote 1 down vote accepted

Have you tried to use Add Field twice? First for fc1 and then another block for fc2. Add Field tool accepts only single table/feature class as input.

It will look similar to: Add Field example

If you have many feature classes and want to add field to each of them then you can use iterators in ModelBuilder (take a look at "Iterate Datasets" section) or convert to python script and use loops if you are convenient with python.

share|improve this answer
    
Yes I did have Add Field three times, but it seemed a bit ridiculous to have three copies of the exactly the same process. Was hoping there was a way to make the model more streamlined. I'll take a look at the iterators, though for only two feature classes I'm not sure if it is worth it for this exercise. Would be useful for the future though. Thanks –  Cindy Williams May 15 '12 at 9:56
    
You should only need two add fields (one for field1 and one for field2). The first takes a list and the second (as you describe it) takes just fc2. You then need two calculate fields (one for Field1 and one for Field2). I don't think an iterator will help you a great deal here –  MappaGnosis May 15 '12 at 10:05
    
Sorry I didn't make that clear, there are two Add Field processes to add field1 to fc1 and fc2, and a third Add Field to add field2 to fc2. Calculate Field is then run on fc1.field1 and fc2.field2. –  Cindy Williams May 15 '12 at 12:32
    
Yes - you can do the first one using a list (or ought to be able to) –  MappaGnosis May 15 '12 at 14:55
    
After consulting with a colleague, he confirmed that for each Add Field operation, I would have to copy and paste the block for each input. Thanks for bringing iterators to my attention! –  Cindy Williams Jun 6 '12 at 6:28

In order to add a field to multiple FeatureClasses, you are still going to have to add the "Add Field" tool into both FC "chains". However, if you want to simply define the characteristics of the field once and apply it to multiple "Add Field" tools, you can call things like Field Name, Field Type, and Field Length out as model Parameters and apply them to multiple Add Field tools, as shown below.

Right-click on Add Field-->Make Variable-->From Parameter-->choose a model characteristic to expose. In this example, the parameter will not be exposed through the user dialog, just to setting through modelbuilder and re-using in multiple tools.

Re-using model parameters for multiple tools

share|improve this answer
    
I did have the characteristics exposed initially, which is how I got to this question as I had three copies of each process (and therefore four properties were exposed in triplicate). I do like this concept though, as it would allow me to change the name of the field to be added to each table once only, rather than having to change it in each copy of the process. –  Cindy Williams May 16 '12 at 5:06

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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