当前位置:网站首页>Arcpy adds fields and loop assignments to vector data

Arcpy adds fields and loop assignments to vector data

2022-04-23 18:00:00 Be happy to study today

Arcpy Add fields to vector data and cycle through modifying values or assignments

As the title shows , What has been generated Arcmap Some simple operations for assignment in the vector attribute table are possible , But I want to add Excel A new column of data in the table needs to use Arcpy To handle . Can be ahead of time in Arcmap Build fields in , Or directly create a new field :

#coding:utf-8
import arcpy
import numpy as np

filename = r'E:\bjdata\data'
arcpy.env.workspace = filename
# path = r"E:\bjdata\result(1000,15).xlsx"
path = r"C:\Users\mianmian\Desktop\result.csv"
wdata=np.genfromtxt(path,delimiter=",") #  open Excel file 

x=wdata[:,13]; # The first 13 Column , All line data 
# print(x)



shp_path = r'E:\bjdata\rightbjnet.shp'
cursor = arcpy.UpdateCursor(shp_path)

i = 1
for my_row in cursor:
    my_value = my_row.getValue('result')
    # print(my_value)
    my_row.setValue('result', float(x[i]))
    cursor.updateRow(my_row)
    i += 1
print(my_value)

版权声明
本文为[Be happy to study today]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230545528514.html