当前位置:网站首页>Arcpy为矢量数据添加字段与循环赋值
Arcpy为矢量数据添加字段与循环赋值
2022-04-23 05:46:00 【今天学习要很快乐鸭】
Arcpy为矢量数据添加字段与循环修改值或赋值
如题目所示,已经生成的Arcmap矢量属性表里对于赋值一些简单的操作时是可以的,但是想添加Excel表格里的一列新数据则需要使用Arcpy的游标来处理。可以提前在Arcmap里建好字段,或者直接新建字段:
#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=",") # 打开Excel文件
x=wdata[:,13]; #第13列,所有行数据
# 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)
版权声明
本文为[今天学习要很快乐鸭]所创,转载请带上原文链接,感谢
https://blog.csdn.net/ShirleyLGY/article/details/115529479
边栏推荐
- 20 excellent plug-ins recommended by idea
- 12. Monkeys climb mountains
- Animation - Introduction to keyframes
- C # Foundation
- Techniques et principes de détection
- Best practices for MySQL storage time
- Rust 中的 RefCell
- 基于pygame库编写的五子棋游戏
- Solution to the trial of ycu Blue Bridge Cup programming competition in 2021
- Storing inherited knowledge in cloud computing
猜你喜欢
Guaba and Computational Geometry
Substring Inversion (Easy Version)
Advanced operation of idea debug
P1586 solution to tetragonal theorem
Rust的闭包类型(Fn, FnMut, FnOne的区别)
Generation of verification code
Export the articles written in CSDN to PDF format
[untitled] database - limit the number of returned rows
[leetcode 54] spiral matrix
批量导出Arcgis属性表
随机推荐
6.Reversal
word排版遇到的格式问题
Usage scenario of copyonwritearraylist
Linux 用rpm的方式安装mysql(超简单)
[leetcode 6] zigzag transformation
P1586 solution to tetragonal theorem
[leetcode 228] summary interval
GDAL+OGR学习
[leetcode 202] happy number
Robocode教程3——Robo机器剖析
xlsxwriter.exceptions.FileCreateError: [Errno 13] Permission denied问题
Option的正确打开方式
[leetcode 459] duplicate substring
Rust 的 Box指针
Optional best practices
自动控制原理知识点整合归纳(韩敏版)
[transfer] MySQL: how many rows of data can InnoDB store in a B + tree?
C language file operation
Collection and map thread safety problem solving
How does MySQL convert stored seconds into dates