• ArcGIS 字段计算器python


    计算顺序编号
    # 计算顺序编号
    # 可访问 esriurl.com/CalculatorExamples 获取更多计算器示例
    rec=0
    def SequentialNumber():
        global rec
        pStart = 1
        pInterval = 1
        if (rec == 0):
            rec = pStart
        else:
            rec = rec + pInterval
        return rec

    累加计算和顺序计算

    根据某间隔值计算顺序 ID 或数字。

    表达式:
    autoIncrement()
    代码块:
    rec=0
    def autoIncrement():
        global rec
        pStart = 1 #adjust start value, if req'd 
        pInterval = 1 #adjust interval value, if req'd
        if (rec == 0): 
            rec = pStart 
        else: 
            rec = rec + pInterval 
        return rec

    计算数值型字段的累加值。

    表达式:
    accumulate(!FieldA!)
    代码块:
    total = 0
    def accumulate(increment):
        global total
        if total:
            total += increment
        else:
            total = increment
        return total

    计算数值型字段的百分比增量。

    表达式:
    percentIncrease(float(!FieldA!))
    代码块:
    lastValue = 0
    def percentIncrease(newValue):
        global lastValue
        if lastValue:
            percentage = ((newValue - lastValue) / lastValue)  * 100
        else: 
            percentage = 0
        lastValue = newValue
        return percentage

    随机值

    通过 numpy 站点包来计算 0.0 和 1.0 之间的随机浮点值。

    表达式:
    getRandomValue()
    代码块:
    import numpy
    def getRandomValue():
        return numpy.random.random()

    使用随机模块来计算 0 与 10 之间的随机整数。

    表达式:
    random.randint(0, 10)
    代码块:
    import random

    计算空值

    在 Python 表达式中,可通过 Python None 来计算空值。

    注注:

    仅当该字段为空时,才可以进行以下计算。

    使用 Python None 计算空值。

    表达式:
    None
  • 相关阅读:
    生成函数初步
    Lg 8月赛(构造+交互)
    wqs 二分学习笔记
    FastAPI 学习之路(十六)Form表单
    线性代数入门
    Oracle-PDB拔插
    MySQL-audit审计插件
    MySQL-用户与权限管理
    MySQL-存储引擎
    MySQL-逻辑结构
  • 原文地址:https://www.cnblogs.com/gisoracle/p/14038097.html
Copyright © 2020-2023  润新知