当前位置:网站首页>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后面加冒号,且均为英文的冒号。
边栏推荐
- 微生物健康網,如何恢複微生物群落
- LeetCode203. Remove linked list elements
- Redis cluster installation
- Interview questions: how to test app performance?
- Quick sort (diagram +c code)
- Cases of agile innovation and transformation of consumer goods enterprises
- What is fake sharing after filling the previous hole?
- 微服務遠程Debug,Nocalhost + Rainbond微服務開發第二彈
- Unity dynamically merges mesh textures
- Understand the session, cookie and token at one time, and the interview questions are all finalized
猜你喜欢
行測-圖形推理-4-字母類
Cases of agile innovation and transformation of consumer goods enterprises
安踏DTC | 安踏转型,构建不只有FILA的增长飞轮
There is another problem just online... Warm
行测-图形推理-1-汉字类
Brush question 3
Quick sort (diagram +c code)
Microbial health network, how to restore microbial communities
ASP. Net core introduction V
Digital transformation: five steps to promote enterprise progress
随机推荐
面试百问:如何测试App性能?
嵌入式音频开发中的两种曲线
Redis集群安装
Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
Brush question 4
LeetCode142. Circular linked list II [two pointers, two methods for judging links in the linked list and finding ring points]
Mitsubishi PLC SLmP (MC) protocol
开发那些事儿:Go加C.free释放内存,编译报错是什么原因?
Line test graph reasoning graph group class
0-5vac to 4-20mA AC current isolated transmitter / conversion module
Innovation today | five key elements for enterprises to promote innovation
Anta DTC | Anta transformation, building a growth flywheel that is not only FILA
Introduction to anomaly detection
How to operate DTC community?
Develop those things: go plus c.free to free memory, and what are the reasons for compilation errors?
数字藏品加速出圈,MarsNFT助力多元化文旅经济!
小程序多种开发方式对比-跨端?低代码?原生?还是云开发?
Txt file virus
软件测评中心▏自动化测试有哪些基本流程和注意事项?
行测-图形推理-6-相似图形类