1

I have an existing ArcGIS 10 geodatabase which has a complicated schema containing multiple tables and joins, and I wish to simplify this for faster web delivery.

For example, Featureclass1 is related to Table1, Table2, TableN, and I wish to copy or import the attributes from each Table onto Featureclass1. This will result in a single Featureclass containing all attributes.

What is the fastest way to do this in a repeatable manner (ie, without doing it manually in ArcCatalog)?

This is what I'm considering:

  • When creating a new featureclass or table in ArcCatalog, there is the option to Import the schema from an existing table/FC. However, this only allows you to import from Table1 (if you then choose Table2, it drops the fields from Table1).

  • The Geodatabase Diagrammer is a great tool for reporting on an existing schema, and designing a new one - but I can't see any options to import multiple fields simply (it seems to require manual entry of each new field).

  • writing a Python script to do it iteratively. Is this the best option?

Note that I'm only concerned with the schema at this stage, not the actual data import.

3

I would personally use arcpy.MakeQueryTable_management and then use that table to create a new featureclass with that as its template.

Please note, that the layer that is created by the tool is temporary and will not persist; you have to use the item created by this, in creating a permanent table

Alternatively, you could just code the creation of the table using arcpy.CreateTable_management, with something like this:

arcpy.CreateTable_management(InputWorkspace,TabName,"",VectorConfigKeyword)

# Process: Add Field
for field in [TabField1,TabField2,TabField3,TabField4,TabField5]:
    arcpy.AddField_management(InputWorkspace + "\\" + TabName, field[0], field[1], field[2],field[3], field[4], field[5], field[6], field[7], field[8])

arcpy.AddIndex_management(InputWorkspace + "\\" + TabName,IndexParams[0],IndexParams[1],IndexParams[2],IndexParams[3])

TabField1 = ["ID","LONG","","","","","NON_NULLABLE","REQUIRED",""]
TabField2 = ["Name","TEXT","","","255","","NON_NULLABLE","REQUIRED",""]
etc
IndexParams = ["ID",TabName + "_RID_IDX","UNIQUE","ASCENDING"]

That way you can design and build your FC anytime you like.

  • Sounds like a Python script might be the best way to do this, then. I'll make a slight change to your script, and read in the fields from the existing tables before writing them to the existing featureclass, rather than specifying the field parameters manually (which is the bit I'm trying to avoid). Thanks – Stephen Lead Oct 5 '11 at 22:22
  • I thought so, but put up some code to point you on your way. To be frank, the more I use arcpy, the more I use it, if you know what I mean; it's a great tool. – Hairy Oct 6 '11 at 6:34

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.