zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    系统吞吐量、TPS(QPS)、用户并发量、性能测试概念和公式[转]
    EF RepositoryBase 参考示例【转】
    Entity Framework 杂碎
    Oracle.ManagedDataAccessDTC.dll 使用
    c# http请求,获取非200时的响应体
    c# windows service(服务)
    git log
    解决冲突
    clone命令
    remote指令添加远程数据库
  • 原文地址:https://www.cnblogs.com/gisoracle/p/14038097.html
Copyright © 2011-2022 走看看