I'm trying to get my head around python integration in ARC. But we don't learn it till next semester, however I see it fit to fulfill my need for my project. (Took second semester project in first)
I'm attempting to take multiple conditions (low, medium, high) and assign a value. 5 = no
results, 4 = low
, and so on till 0 = not present
.
I understand this is using a while loop?
IE
def Condition (field_16,field_8):
While field_8 == "choice0":
if value(or is this field_16) == "choice0"
return "5"
Etc, can anyone give me a tip or shell?
And then the condition = Condition (!field_16!)
Little stuck with python in arc.
Thanks!
Update Cursors are often used instead of the field calculator in ArcGIS to update row values. The cursor syntax is usually more intuitive than the field calculator interface. For example:
import arcpy
fc = r'C:\path\to\your.gdb\feature_class'
with arcpy.da.UpdateCursor(fc, ["some_value_field", "some_field_to_write_values"]) as cursor:
for row in cursor:
"""
note that row[0] refers to "some_value_field"
and row[1] refers to "some_field_to_write_values"
"""
if row[0] == "low":
row[1] = 4
elif row[0] == "no":
row[1] = 5
elif row[0] == "not present":
row[1] = 0
cursor.updateRow(row)