1

I have two files:

  • a shapefile called: Habitat.shp
  • from the ZonalStatisticsAsATable-function a .dbf-file: ZonalStatisticsTable.dbf.

In the .dbf-file is a coloumn in which I am interested. It is the MEAN-coloumn. I want to join that field to the shapefile. Since I am forced to use the shapefile (there is no way a GDB is possible), I wanted basically to join the MEAN-coloumn to the shapefile and change then the name to Fox_Mean. Here is my code:

Habitat="C:\\Files\\Habitat.shp"
ZonalStatisticsOutputTable="C:\\Files\\ZonalStatisticsTable.dbf"
arcpy.JoinField_management(Habitat, "ZoneID", ZonalStatisticsOutputTable, "ZoneID", "MEAN")
arcpy.AlterField_management(Habitat, "MEAN", "Fox_Mean")

However since I am working on a shapefile the AlterField_management-tool does not work.

Is there any other way of renaming that MEAN-field without using GDB or any other additional library?

I thought maybe about simply renaming the MEAN-field in the .dbf-file, but then a new library is needed. An alternative would maybe be to just copy the content of the coloumn to a new field and delete the MEAN-field then. However I am unsure if that does not screw everything up.

5

Creating the new field, calculating it, and deleting the old field is the way to go.

arcpy.AddField_management (Habitat, "Fox_Mean", "DOUBLE")
arcpy.CalculateField_management (Habitat, "Fox_Mean", "[MEAN]")
arcpy.DeleteField_management (Habitat, "MEAN")

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.