import arcpy from arcpy import env from arcpy import mapping arcpy.env.overwriteOutput = True # Set Local Variable A = "CUPS" #Layer you want to updat acres mxd = arcpy.mapping.MapDocument("CURRENT") # Create attribute called Acres try: if arcpy.Exists(A): arcpy.AddField_management(A, "Acres", "DOUBLE") print "Acres Attribute Added" else: print "Acres Field Not Added" except arcpy.ExecuteError: print "Error Occured Add Acres Attribute Failed" print (arcpy.GetMessages(2)) # Create curser to update acres field cur = arcpy.UpdateCursor(A) # Pass through each row to update acres value try: if arcpy.Exists(A): for row in cur: row.Acres = row.Shape_Area /43560 cur.updateRow(row) print "Acres Updated" else: print "Acres Not Updated Feature Class Does Not Exist" except arcpy.ExecuteError: print "Error Occured Update Failed" print (arcpy.GetMessages(2)) del cur, row arcpy.RefreshActiveView() arcpy.RefreshTOC() # Delete cursor and objects del arcpy, env, A, mxd
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.