FeatureClassToGeodatabase creating output with incorrect feature class name

2392
3
Jump to solution
01-13-2012 07:13 AM
PatrickPanza
New Contributor II
I am currently writing some scripts to pull data down from an SDE and store it locally in a file GDB, with some fun little tweaks to "check-in" recent local edits to the feature class into the latest SDE version of the file.  Everything should be fairly straightforward, as designed, but I've hit a snag very early in the process with the FeatureClassToGeodatabase_conversion results.  The resulting feature class in the file GDB is always named "GPL0" instead of its original name!!  Does anybody know why this is happening?

I've tried this three ways:

1. exporting from a layer located in an MXD.  This layer points to the original SDE dataset.  Result: feature class is successfully imported into the local file GDB but the feature class name is always "GPL0" instead of its original name.
2. exporting from a lyr file stored locally.  This lyr file points to the original SDE dataset.  Result: feature class is successfully imported into the local file GDB but the feature class name is always "GPL0" instead of its original name.
3. exporting from a SHP file stored locally.  This SHP file was created by simple ArcMap export from the original SDE dataset.  Result: feature class is successfully exported into the local file GBD maintaining its original name.

Here is my problem...option 3 doesn't work for me, because creating the SHP file truncates a lot of important field names.  Obviously the issue lies in exporting SDE data directly, but I don't see any way in the FeatureClassToGeodatabase process to specify a name.  I can make the assumption that the export will always be named "GPL0" and then throw a Rename into the script to get it back to the original name, but that's messy and since I don't know WHY this "GPL0" stuff is happening, I can't rely on it happening forever.  Any help would be appreciated!

Here is the code for each method I've tried:

Option 1 (layer in MXD as source)
import arcpy from arcpy import mapping  # set location of MXD which contains layer to be exported ExportBase = r"P:\filepath\ExportBase.mxd"  # set export process variables mxd = mapping.MapDocument(ExportBase) sourceLyr = mapping.ListLayers(mxd, "data_from_SDE") outLocation = r"P:\filepath\sampleGDB.gdb"  # execute export SDE layer from MXD to GDB arcpy.FeatureClassToGeodatabase_conversion(sourceLyr, outLocation)


Option 2 (lyr file pointing to SDE data as source)
import arcpy from arcpy import mapping  # set export process variables sourceLyr = mapping.Layer(r"P:\filepath\sampleLYR.lyr) outLocation = r"P:\filepath\sampleGDB.gdb"  # execute export lyr file to GDB arcpy.FeatureClassToGeodatabase_conversion(sourceLyr, outLocation)



Option 3 (SHP file as source)
import arcpy  # set export process variables sourceLyr = r"C:\filepath\features.shp" outLocation = r"C:\filepath\sampleGDB.gdb"  # execute export layer from SHP to GDB arcpy.FeatureClassToGeodatabase_conversion(sourceLyr, outLocation)
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Use the 'arcpy.FeatureClassToFeatureClass_conversion' function.  This will allow you to specify the output feature class name.

View solution in original post

3 Replies
JakeSkinner
Esri Esteemed Contributor
Use the 'arcpy.FeatureClassToFeatureClass_conversion' function.  This will allow you to specify the output feature class name.
PatrickPanza
New Contributor II
Use the 'arcpy.FeatureClassToFeatureClass_conversion' function.  This will allow you to specify the output feature class name.


Well, that was simple enough.  Thank you!
0 Kudos
AllanBenvin
New Contributor III
I'm doing something similar but I am trying to export annotation. I also want it to be in a consistent projection with my target database so I am importing it into an existing feature dataset. I get different useless results based on the method.

Using ArcObjects with Geoprocessor object
1) If I use FeatureClassToGeodatabase_conversion then the data comes out okay but the name of the output layer is always GPL0 or GPL0_x. The resulting annotation will display fine on the map but I need to be able to control the name.

2) If I use FeatureClassToFeatureClass_conversion then I can control the name of the output dataset but my annotation is hosed.
The internal columns such as ANNOTATIONCLASSID, TEXTSTRING, FONT etc are all null. The resulting annotation will not display on the map.

These above commands seem to correspond operations in ArcCatalog.
Using ArcCatalog:
1) If I right click on the target feature dataset and select Import:Feature Class (multiple) then the data comes out okay and it is named the same as the source. The resulting annotation will display fine on the map. It seems like this is doing the same thing as FeatureClassToGeodatabase_conversion in that the data is actually good but the gp object randomly names the result and the ArcCatalog tool forces the name. I'm guessing there is a rename going on here after the process.

2) If I right click on the target feature dataset and select Import:Feature Class (single) then I can control the name of the output dataset but my annotation is hosed. The internal columns such as ANNOTATIONCLASSID, TEXTSTRING, FONT etc are all null. The resulting annotation will not display on the map.
0 Kudos