当前位置:网站首页>ArcGIS:字段赋值_属性表字段计算器(Field Calculator)依据条件为字段赋值
ArcGIS:字段赋值_属性表字段计算器(Field Calculator)依据条件为字段赋值
2022-07-07 21:50:00 【BetterQ.】
当对ArcGIS中所加载数据属性表中的字段进行赋值时,可以点击“开始编辑”后手动为字段进行赋值,但当数据量较大时就需要使用Python来对其进行赋值。
打开属性表后,点击要为赋值的字段,右键点击选择“字段计算器”,如下图:
直接统一赋值:
直接在输入框中输入数字或者字母或者文字即可为该字段统一赋值。
.
.
按条件赋值:
当需要按条件赋值时,可以输入以下脚本进行:
.
def cal(f)
if f=='s':
return 1
if f=='a':
return 2
else:
return 99
如果需要根据值的大小为字段赋值可以输入如下代码:
def cal(f)
if f>50:
return 1
if f<100 and f>60:
return 2
else:
return 99
注意:
1、 由于使用的是python来进行编写,所以要格外注意空格和对齐,一般为缩进4个/8个空格,但是有时候也会是3个/7个空格。出现问题一般是因为空格缩进不对。
2、 当使用到文字时,需要对其进行转码,转为utf-8格式才可以被识别,如下:
def cal(f)
if f==('草地'.decode(utf-8)):
return 1
if f==('林地'.decode(utf-8)):
return 2
else:
return '其他'.decode(utf-8)
3、 不要忘记if后面加冒号,且均为英文的冒号。
边栏推荐
- Debezium series: introducing support for the final operator
- QT graphicsview graphical view usage summary with flow chart development case prototype
- 软件测评中心▏自动化测试有哪些基本流程和注意事项?
- 数字藏品加速出圈,MarsNFT助力多元化文旅经济!
- Brush question 3
- Innovation today | five key elements for enterprises to promote innovation
- Debezium系列之:支持 mysql8 的 set role 语句
- GBU1510-ASEMI电源专用15A整流桥GBU1510
- Yarn cannot view the historical task log of yarn after enabling ACL user authentication. Solution
- ASEMI整流桥KBPC1510的型号数字代表什么
猜你喜欢
Leetcode206. Reverse linked list
Early childhood education industry of "screwing bar": trillion market, difficult to be a giant
Use JfreeChart to generate curves, histograms, pie charts, and distribution charts and display them to jsp-2
It's no exaggeration to say that this is the most user-friendly basic tutorial of pytest I've ever seen
Brush question 4
GBU1510-ASEMI电源专用15A整流桥GBU1510
Line test - graphic reasoning - 6 - similar graphic classes
iNFTnews | NFT技术的广泛应用及其存在的问题
今日创见|企业促进创新的5大关键要素
PCL . VTK files and Mutual conversion of PCD
随机推荐
Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
[network] Introduction to C language
Software test classification
微生物健康网,如何恢复微生物群落
关于海康ipc的几个参数
Line test - graphic reasoning - 3 - symmetric graphic class
Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
There is another problem just online... Warm
Debezium series: introducing support for the final operator
oc 可变參数传递
ASEMI整流桥KBPC1510的型号数字代表什么
Take full control! Create a "leading cockpit" for smart city construction
Class implementation of linear stack and linear queue (another binary tree pointer version)
Ligne - raisonnement graphique - 4 - classe de lettres
Early childhood education industry of "screwing bar": trillion market, difficult to be a giant
Txt file virus
Visual studio 2019 installation
Mitsubishi PLC SLmP (MC) protocol
DTC社群运营怎么做?
Txt file virus