I've written a script in Python for ArcGIS 10.1 in order to migrate from an outdated coordinate system to a newer one while at the same time updating from personal geodatabases (.mdb) to file geodatabases (.gdb)- Everything works fine except:
When the tool tries to copy OR reproject (which I guess has to copy data as well) from a database containing a feature class with the same name as the featuredataset it fails, giving a 000171 Error 'Failed to open output workspace.
Changing the name of the feature dataset to something else will make it work (i.e. database.gdb\different\same Changing the name of the feature class to something else will make it work (i.e. database.gdb\same\different)
I can see an easy workaround by just renaming stuff a couple of times, but I want to get to the bottom of it if possible- It's a very fringe case that doesn't affect many of the databases so I want to avoid more code just to handle this case if possible. It seems OK to create these duplicate names using normal methods (i.e. ArcCatalog won't stop you) and the inbuilt geo-processing tools in ArcToolbox (i.e. Project) don't fail in the same situation....it's just the arcpy library it seems?
(edit code added - Thanks to KimOs suggestion, the copy portion under the else statement now works- The projection still doesn't. All data has its projection defined correctly.)
FCs =arcpy.ListFeatureClasses('*','All',dataset) # list feature classes within this feature dataset arcpy.AddMessage("Found these feature classes: " + str(FCs)) for FC in FCs: # for the feature classes within a feature dataset descFC= arcpy.Describe(FC) if descFC.spatialReference.name == 'GD_1949_New_Zealand_Map_Grid': # reproject only NZMG data arcpy.AddMessage(FC + " is NZMG, reprojecting to: " + newFD + descFC.baseName) logging.info(FC + " is NZMG, reprojecting to: " + newFD + descFC.baseName) arcpy.Project_management(FC, newFD + descFC.baseName, prjFile, 'New_Zealand_1949_To_NZGD_2000_3_NTv2', descFC.spatialReference) else: # else just copy it across arcpy.AddMessage(FC + " is in " + str(descFC.spatialReference.name) + " , copying instead: " + newFD+ descFC.baseName) logging.info(FC + " is in " + str(descFC.spatialReference.name) + " , copying instead: " + newFD+ descFC.baseName) arcpy.Copy_management(FC,newFD + descFC.baseName, "FeatureClass")