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
  • 相关阅读:
    asp.net(C#)利用QRCode生成二维码(续)-在二维码图片中心加Logo或图像
    C#中DataTable中的Compute方法使用收集
    c#的DateTime.Now函数详解
    附加数据库失败,拒绝访问
    xml文件绑定chenckbox选择框
    Maximum Xor Secondary(单调栈好题)
    Y(类树形DP)
    Average distance(类树形DP)
    Balls and Boxes (模拟题)
    Party at Hali-Bula(树形DP+判断方案数是否唯一)
  • 原文地址:https://www.cnblogs.com/gisoracle/p/14038097.html
Copyright © 2011-2022 走看看