AnsweredAssumed Answered

Simple VB or Python Expression to change multiple attribute values in one column

Question asked by JacobBpunkt on Aug 8, 2018

Hey, i am currently working on a student project and i am facing to tasks, that probably needs a greater knowledge in Python or VB-scripting than i have. I am working with a crop type data set in southern Germany.


First Task: Simply change the Values within the column (not in a new column) - The CropTyp Code changes from one value to another:

 

Field = CropTyp

1 -> 14         10 -> 3

2 -> 11         11 -> 14

3 -> 12         12 -> 18

4 -> 10         13 -> 5

5 -> 9           14 -> 2

6 -> 7           15 -> 15

7 -> 17         16 -> 16

8 -> 6           17 -> 1

9 -> 4           18 -> 8

 

I have already done this by a if-else-then function in Excel and joining the new data BUT i now have to change the values in the ArcGIS Modulbuilder using tools like "Calculate Field".

 

My second Task: I now have to calculate a new field called: "Kc" (which is the plant coefficient) by Adding "Add Field" Field Name: "Kc" in the Modelbuilder) - i now have to calculate a value that is based on the "CropTyp" Field.
e.g.: Field1: "Croptyp" = 1 -> Field2: "Kc" = 1,15

 

CropTyp ->  Kc

1 -> 1,15         10 -> 1,075

2 -> 1,15         11 -> 1,15

3 -> 1,15         12 -> 1,2

4 -> 1,15         13 -> 1,2

5 -> 1,15         14 -> 1,2

6 -> 1,15         15 -> 1,05

7 -> 1,05         16 -> 0,7

8 -> 1,15         17 -> 1,15

9 -> 1,15         18 -> 1,15

 

Can anyone help my with one or both tasks? How could the pre-logic script code and the codeblock look like?

Thanks in advance!

Jacob

Outcomes