当前位置:网站首页>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后面加冒号,且均为英文的冒号。
边栏推荐
- Unity FAQ (I) lack of references
- LeetCode203. Remove linked list elements
- Microservice Remote debug, nocalhost + rainbond microservice Development second Bomb
- Cascade-LSTM: A Tree-Structured Neural Classifier for Detecting Misinformation Cascades-KDD2020
- Micro service remote debug, nocalhost + rainbow micro service development second bullet
- 一次搞明白 Session、Cookie、Token,面试问题全稿定
- Take full control! Create a "leading cockpit" for smart city construction
- Quick sort (diagram +c code)
- Sword finger offer 28 Symmetric binary tree
- Software test classification
猜你喜欢

iNFTnews | Web5 vs Web3:未来是一个过程,而不是目的地

Software test classification

I wish you all the best and the year of the tiger

小程序多种开发方式对比-跨端?低代码?原生?还是云开发?

Line test - graphic reasoning - 4 - alphabetic class

Understand the session, cookie and token at one time, and the interview questions are all finalized

Transform XL translation

【刷题记录】3. 无重复字符的最长子串

Sword finger offer 55 - I. depth of binary tree

消费品企业敏捷创新转型案例
随机推荐
Locate to the bottom [easy to understand]
Visual studio 2019 installation
Debezium series: MySQL tombstone event
消息队列与快递柜之间妙不可言的关系
30讲 线性代数 第五讲 特征值与特征向量
Early childhood education industry of "screwing bar": trillion market, difficult to be a giant
Unity dynamically merges mesh textures
Basic knowledge of binary tree
Online interview, how to better express yourself? In this way, the passing rate will be increased by 50%~
Leetcode94. Middle order traversal of binary trees
Line test graph reasoning graph group class
LeetCode142. Circular linked list II [two pointers, two methods for judging links in the linked list and finding ring points]
软件测评中心▏自动化测试有哪些基本流程和注意事项?
7-51 combination of two ordered linked list sequences
不夸张地说,这是我见过最通俗易懂的,pytest入门基础教程
Some parameters of Haikang IPC
Software evaluation center ▏ what are the basic processes and precautions for automated testing?
Redis集群安装
Brush question 5
行测-图形推理-7-相异图形类