I am using ArcGIS 10.1 for Desktop.
My goal is to create shapefile that contains merged feature classes from a geodatabase. I would like for there to be a new field in the resulting shapefile that contains the name of the original feature class. The tool that I have created is successful in merging the FCs into one shapefile however the "Name" field is blank for ever record.
The field that is intended to be populated is set up as a text field (length 50). I have set the "Name" variable from Iterate Feature Classes as a precondition to calculate field. My expression in Calculate field is "%Name%" with Expression Type Python.
What do I need to change to make this work?
Link to Image : https://i.sstatic.net/pUAnO.jpg
enter image description here
-
1I think your model needs to include Parse Path.PolyGeo– PolyGeo ♦2013年09月12日 21:49:08 +00:00Commented Sep 12, 2013 at 21:49
3 Answers 3
I followed the suggestion provided by @PolyGeo and I used the "NAME" component of Parse Path to populate Calculate Field. I connected the "Value" variable from Parse Path as a pre-condition to Calculate value. This solution was successful. This is what my final model looks like:
https://i.sstatic.net/thXlt.jpg
enter image description here
-
@PolyGeo - why is it necessary to use Parse Path - Parse Type:Name when this value is already available through the Name variable from the iterator?Nxaunxau– Nxaunxau2013年09月17日 12:15:15 +00:00Commented Sep 17, 2013 at 12:15
-
@PolyGeo, I have the same question, when I used the iterator "Iterate Feature Selection", I was able to directly link the "Value" variable to the Field Calculator. gis.stackexchange.com/questions/64562/…kkaszas– kkaszas2013年09月17日 16:10:58 +00:00Commented Sep 17, 2013 at 16:10
I was experiencing a similar issue with my iterating model. I was calculating a field in a series of tables to equal the names of the tables. I was left with blank fields. Since the data type is string, the expression needed to include quotes around the substituted variable, such as '%Name%' as opposed to %Name%.
With this change, the model worked as expected.
Your calculate field expression is ok. It should produce the intended result. I would modify the model so that the merge is done in a separate model that calls a sub model. Sub model copies features, adds and calculates field with feature class name, collects and passes the values to merge tool in the main model.
Explore related questions
See similar questions with these tags.