Select to view content in your preferred language

How to add a field and auto-populate for several feature classes?

774
2
03-31-2017 02:49 PM
ShaneShepherd
Deactivated User

Hi everyone,

I'm relatively new to ArcGIS, so please forgive my lack of knowledge. I have ~100 feature classes that I am going to combine into a single feature class, but before I do I want to add a field to each of their attribute tables, then have that field auto-populate from a value at the end of the name of the feature class. Is it possible to use a tool to do this all at once? All I know to do right now is manually add a field to each feature class one at a time, and then use the Field Calculator to populate the values.

Thanks for any help!

0 Kudos
2 Replies
ChrisDonohue__GISP
MVP Alum

There's two common ways to do this - using either Python or Modelbuilder.  I'm not great at Python, so I will a discussion of how to do it with that to others.  As for Modelbuilder, here's what you could do:

1.  Place copies of all the feature classes in one folder, preferably with a short folder chain to the root.

2.  Design a Model using Modelbuilder with the following components:

- Iterate ______ (Modelbuilder-only tool) - this will loop through all the feature classes to run the following processes.  Choose the appropriate Iterator to match your data.

- Add Field geoprocessing tool

- Calculate Field geoprocessing tool

Note that the Calculate field would use the Value or Name output from the Iterate to populate the file name via the use of a

Inline Variable Substitution.

What is ModelBuilder?—Help | ArcGIS for Desktop 

ArcGIS Help (10.2, 10.2.1, and 10.2.2) - Iterator Examples

ArcGIS Help (10.2, 10.2.1, and 10.2.2) - Inline Variable Substitution

After the model is run and all the feature classes now have the new field with the calculated value, you can run a Union geoprocessing tool to combine them.

Chris Donohue, GISP

ShaneShepherd
Deactivated User

Thanks so much Chris! I'll give this a try, I really appreciate the help.

0 Kudos