3

I have 8 separate geodatabases in which are contained tiled feature classes all of the same name e.g. TopographicArea. So that each of my File Geodatabases contain a feature class called TopgraphicArea etc..

I would like to be able to merge the feature classes from each geodatabase of the same type (e.g all feature classes called TopgraphicArea etc..) but as it stands I can't because the names are identical.

How can I rename, or append a suffix to, each feature class so that they can subsequently be merged?

Ideally I'd like the feature classes in gdb1 to be "1" in gdb2 to be "2" and so on and preferably to be done in ModelBuilder.

5
  • By "merge", do you mean copying featureclasses to an output geodb such that gdb/TopographicArea1, gdb/TopographicArea2... are copies of the featureclasses gdb1/TopographicArea, gdb2/TopographicArea ? Commented Jul 29, 2015 at 15:16
  • Since you are only dealing with 8 geodatabases, and thus, 8 feature classes, it almost seems like this is making it more complicated than it needs to be. I don't mean that to be condescending because I get caught in the same trap. I try to automate something, when the reality is that simply doing it by hand is just as fast. In this case, I mean going in through ArcCatalog, right-clicking each feature class and renaming it. If there is a reason this won't work, definitely please modify your question to add some more detail. Commented Jul 29, 2015 at 15:18
  • Have you seen this question? You could adapt that code and put it in the python console in arcmap..
    – mr.adam
    Commented Jul 29, 2015 at 15:18
  • @GetSpatial you're totally right, I just feel like it's something I SHOULD be doing in an automated way.
    – MyFamily
    Commented Jul 29, 2015 at 15:18
  • @KirkKuykendall yes an output .gdb
    – MyFamily
    Commented Jul 29, 2015 at 15:19

1 Answer 1

2

This code is pretty simple, but it should work for what you want to do. Again, in the time it took to write the code, you could rename the featureclasses by yourself, but the logic works if you need to scale it up to a larger number.

import arcpy
from arcpy import env

# Set Output Geodatabase Name
outgdb = "C:/workspace/outfc.gdb"

#Set Range to cycle Through
for num in range(1,8):
  #Set workspace to gdb name and iterator number
  env.workspace = "C:/workspace/gdb" + num + ".gdb"
  #List featureclasses in that workspace
  fclist = arcpy.ListFeatureClasses()
  #Iterate through featureclasses
  for fc in fclist:
    oldnm = fc
    #Rename featureclasses to old name plus iterator
    newnm = fc + num
    arcpy.Rename_management(oldnm, newnm, "FeatureClass")
    #Copy renamed featureclasses into Output Geodatabase
    newloc = outgdb + os.sep + newnm
    arcpy.Copy_management(newnm, newloc, "")
2
  • Python is pretty easy with mashing types together. I've done similar before with no problems. Commented Jul 29, 2015 at 18:35
  • 1
    Perfect, I renamed them manually yesterday but wanted to test the logic as it's something that'll have to be repeated and possibly with more GDBs and this worked perfectly - many thanks.
    – MyFamily
    Commented Jul 30, 2015 at 8:14

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.