1

I have a several file geodatabase with seven features in it (polygon). I want to copy them to a new feature in a other empty file geodatabase (instead of deleting the fields...had same problems with that tool)

What I want: I just need 20 out of 60 fields and in the new feature in a new order. I tried to set up this in Modelbuilder, but there a several problems which I don't get. I will use the iterator for features thats clear. No problem. Then feature to feature tool. Up to this point is clear to me. I create a variable with my necessary field names in the order I want them. clear to me. But what is not clear:

  1. How to say take this list every time for each feature for the field map?
  2. How to reorder them? like variable-list has it?

Is it possible with model builder or do I need a script for that? I have around three million polygons in each feature...


I see my english expression was not the best. I am german ;-) I will simple it a bit easier.

One Filegeodatabase contents: 7 features(polygons) and around 3 million attributes and 60 fields. And I have 4 of this filegeodatabases... Each field in each feature is same by name. It is a result of many intersection steps. But for the end product, I just need 20 of this fields in my desired order. Yes, I agree to you, I can use the tool, but so I have to click 40 times of each to have my new feature but i cannot move the order in the "fieldmap"-window.

The other option what I could do is, to copy the feature first into the new filegeodatabase and delete the unwanted fields, but at the end it is same clicking time which i not have, so it must be working automated or? In the delete field tool, it brings check boxes, I can select all or unselect all and search through the fields where are my wanted and so i could get it. I can do it for one. And i can not recall the tool from the resultslist, because then he reads the list of the feature again, and i can start choosing again... is this cleared explained? On searching the net, i didnt find any useful solution. The example-code of delete-tool in the arcgis-help resource i could not get to run...

8
  • Would you be able to edit your Question to indicate the version of ArcGIS for Desktop that you are using, please?
    – PolyGeo
    Commented Jun 12, 2014 at 12:54
  • Oh, yes I forget it. I use ArcGIS Desktop 10.1 SP1 with all Extensions(at University).
    – user32330
    Commented Jun 12, 2014 at 13:01
  • Couldn't you just select the fields you want and then export them?
    – GISHuman
    Commented Jun 12, 2014 at 13:30
  • Clarify. Several with seven features in it. Seven in each or seven total. You want to copy features to a new features? I ham having a hard time understanding what you want to achieve. It seems to me GISKid has a point. Commented Jun 12, 2014 at 13:40
  • @GISKid, since each fc probably has a different database schema using an iterator there is not an easy way to select certain field(s) using ModelBuilder.
    – artwork21
    Commented Jun 12, 2014 at 13:40

1 Answer 1

2

I've had little success in re-ordering fields in model builder, not sure if one can even do that? I had written a bit of python that could create a new table that would create an output table with the fields in a user specified order, the code is below, you could adapt it for your needs.

In this example a table with 4 fields is reordered and stored IN_MEMORY.

inputTable = "ABC" # This is a table loaded into ArcMap
outputTable = "XYZ"

# Get field mappings of Input Table
fieldMappings = arcpy.FieldMappings()
fieldMappings.addTable(inputTable)

# Create an empty FieldMappings Object
newFieldMappings = arcpy.FieldMappings()

# Add fields in desired order. Note field index must be known
newFieldMappings.addFieldMap(fieldMappings.getFieldMap(3))
newFieldMappings.addFieldMap(fieldMappings.getFieldMap(0))
newFieldMappings.addFieldMap(fieldMappings.getFieldMap(2))
newFieldMappings.addFieldMap(fieldMappings.getFieldMap(1))

# Create Table
arcpy.TableToTable_conversion(inputTable, "IN_MEMORY", outputTable, None, newFieldMappings)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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