当前位置:   article > 正文

Arcgis pro 字段计算器 python3常用方法二_arcgis pro计算值代码块

arcgis pro计算值代码块

一、使用代码块简介

        举例见下图

 上例:将多边形几何面积取一位小数写入【TBYBH】字段

二、常用功能块

1、按地类名称字段值,对地类代码字段赋值,代码块名称为:DLZH
      调用表达式:DLZH(!DLMC!)
      块代码:

  1. def DLZH(x):
  2. if x==u"水田":
  3. return "0101"
  4. elif x==u"水浇地":
  5. return "0102"
  6. elif x==u"旱地":
  7. return "0103"
  8. else:
  9. return "非耕地"

2、按地类代码进行土地三大类分类,代码块名称为:DL3DL
      DL3DL(!DLBM!)

  1. def DL3DL(DLFL):
  2. if (DLFL =="0101" or DLFL =="0102" or DLFL =="0103" ):
  3. return "耕地"
  4. elif (DLFL == "0201" or DLFL =="0202" or DLFL =="0203" or DLFL =="0204" or DLFL =="0301" or DLFL =="0301" or DLFL =="0302" or DLFL =="0303" or DLFL =="0304" or DLFL =="0305" or DLFL =="0306" or DLFL =="0307" or DLFL =="0401" or DLFL =="0402" or DLFL =="0403" or DLFL =="1006" or DLFL =="1103" or DLFL =="1104" or DLFL =="1107" or DLFL =="1202" or DLFL =="1203"):
  5. return "其他农用地"
  6. elif (DLFL == "05H1" or DLFL == "0508" or DLFL == "0601" or DLFL == "0602" or DLFL == "0603" or DLFL == "0701" or DLFL == "0702" or DLFL == "08H1" or DLFL == "08H2" or DLFL == "0809" or DLFL == "0810" or DLFL == "09" or DLFL == "1001" or DLFL == "1002" or DLFL == "1003" or DLFL == "1004" or DLFL == "1005" or DLFL == "1007" or DLFL == "1008" or DLFL == "1009" or DLFL == "1109" or DLFL == "1201"):
  7. return "建设用地"
  8. elif (DLFL == "0404" or DLFL == "1101" or DLFL == "1102" or DLFL == "1105" or DLFL == "1106" or DLFL == "1108" or DLFL == "1110" or DLFL == "1204" or DLFL == "1205" or DLFL == "1206" or DLFL == "1207"):
  9. return "未利用土地"
  10. else:
  11. return "没有对应关系地类"

3、计算某要素中的折点数。代码块名称为:getVertexCount

调用表达式:getVertexCount(!shape!)

  1. def getVertexCount(feat):
  2. partnum = 0
  3. partcount = feat.partCount
  4. pntcount = 0
  5. while partnum < partcount:
  6. part = feat.getPart(partnum)
  7. pnt = part.next()
  8. while pnt:
  9. pntcount += 1
  10. pnt = part.next()
  11. if not pnt:
  12. pnt = part.next()
  13. partnum += 1
  14. return pntcount

4、根据某间隔值计算顺序 ID 或数字,代码块名称:autoIncrement
表达式:autoIncrement(10, 5)     ,调用初始值为10,每次递增5

  1. rec = 0
  2. def autoIncrement(start=1, interval=1):
  3. global rec
  4. if rec == 0:
  5. rec = start
  6. else:
  7. rec += interval
  8. return rec

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/310987
推荐阅读
相关标签
  

闽ICP备14008679号