0

I'm using the following snippet to import a shapefile into a SDE feature class.

arcpy.CopyFeatures_management(inputShapefile, outputFeatureClassName)

where inputShapefile is a shapefile on a mapped drive and outputFeatureClassName is a feature class that will be created on our SDE server.

With the exception of a single field name, all field names in the shapefile appear in the SDE feature class. The exception field is named "AREA" in the shapefile but somewhere along the way it is prefixed with SCHEMA.TABLENAME. Instead of a field named "AREA", it is named "ABC123.tmp.AREA".

I checked the feature class properties in ArcCatalog and this field has an alias that matches what I'm describing. My question, how to I prevent this from happening? I want the field name imported as-is.

update #1 - I tried to fully qualify outputFeatureClassName in the call to arcpy.CopyFeatures_management() , instead of just setting arcpy.env.workspace at the beginning of my code. Still experiencing this issue.

update #2 - In the SDE database, the field is named AREA. How do I prevent the alias from being created? None of the other fields have aliases of this form.

  • Are you sure it's not just an alias displaying in sde and not the actual field name, as it is in the shapefile? – recurvata Mar 20 '15 at 17:16
  • @recurvate okay so in the SDE database, the field is named like I want ("AREA") and how it is in the SHP. Why is the alias created and how do I prevent it from happening? – DenaliHardtail Mar 20 '15 at 17:20
  • I don't know that you can, since the alias is in the original data. I don't see any options to ignore it. You may be able to set display in SDE to show field names rather than alias, but we don't have SDE so I can't really say. In a file geodatabase, there's an option in the attribute table menu to show aliases or not. – recurvata Mar 20 '15 at 17:26
  • Columns in databases are referred to by their parent table and database (database.table.column). This is a just the way it is. You can set an alias, but the default is to use the true column name. – Vince Mar 20 '15 at 17:58
  • 1
    Area is a function in enterprise geodatabases (a request upon the shape object to report its area) – Vince Mar 20 '15 at 18:15
1

While you may not be able to prevent the alias from changing, you should be able to change it back easily enough with a few more lines of code. Say fc is your variable for the new feature class. Change the AREA field alias this way:

for field in arcpy.ListFields (fc):
    if field.name == "AREA":
        field.alias = "AREA"

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.