Quantcast
Channel: Question and Answer » arcpy
Viewing all articles
Browse latest Browse all 767

Field Calculator Python Issues [closed]

$
0
0

How can I adapt the following expression in the ArcGIS field calculator? Below is the python code:

import arcpy
fc = "2014_2"
keyField = "ID_segment"
affectedField = "KKN2"
maxVal = 2500
cnt = 1
Value = -1
oldValue = str(maxVal)
queryString = '"' + keyField + '" < ' + "" + oldValue + ""
rows2 = arcpy.UpdateCursor(fc, queryString)
row2 = rows2.next()
while row2:
        iValue = row2.getValue("ID_segment")
        if iValue != Value :
                cnt = 1
                Value = iValue
        else :
                cnt = cnt + 1
        kVal = str(row2.getValue("KKN")) + "/" + str(cnt)   
        print(Value,kVal)
        row2.setValue(affectedField, kVal)
        rows2.updateRow(row2)
        row2 = rows2.next()

enter image description here

enter image description here


Viewing all articles
Browse latest Browse all 767

Trending Articles