Easily Calculate ALL Fields ON one click in ArcMap Attribute Table

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ม.ค. 2025

ความคิดเห็น • 1

  • @SFAACLUB
    @SFAACLUB  4 หลายเดือนก่อน

    >>> import arcpy
    ...
    ... # Define the shapefile path
    ... shapefile_path = r"D:\PULSE Jhelum\only khasra\79695_DIWALIAN\VECTOR_FINAL\79695_DIWALIAN_KHASRA.shp"
    ...
    ... # User inputs
    ... District = "Jhelum" #Jhelum,Chakwal,Talagang
    ... Dist_ID = 37
    ... Tehsil = "Jhelum"
    ... Tehsil_ID = 129
    ... QH = "Kala Gojran"
    ... QH_ID = 764
    ... PC = "Jakkar"
    ... PC_ID = 6979
    ... Mouza = "Bahbondana Gargan"
    ... Mouza_ID = 80287
    ... Karam = 5.5
    ... Type = "Kishtwar"
    ...
    ... # Create a list of fields and corresponding values
    ... fields = ["District", "Dist_ID", "Tehsil", "Tehsil_ID", "QH", "QH_ID", "PC", "PC_ID", "Mouza", "Mouza_ID", "Karam", "Type"]
    ... values = [District, Dist_ID, Tehsil, Tehsil_ID, QH, QH_ID, PC, PC_ID, Mouza, Mouza_ID, Karam, Type]
    ...
    ... # Start an edit session and update the fields
    ... with arcpy.da.UpdateCursor(shapefile_path, fields) as cursor:
    ... for row in cursor:
    ... for i in range(len(fields)):
    ... row[i] = values[i]
    ... cursor.updateRow(row)
    ...
    ... print("Fields updated successfully.")