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.

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 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.

Thanks

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

Or have I missed what you want?

share|improve this answer
    
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
add comment

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.