1

I add a field called Name in attribute table in arcgis 10.1 but I can't edit this field. From this site, I have learned that this can be done by field calculator using VBscript or Python. As I have very little knowledge in Visual Basic or Python, it becomes difficult for me to enter an expression using this programming language. In the picture shown, I created four category which I want to put in the Name section according to their GRIDCODE.

Can anyone tell me how can I do this ?

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jun 16, 2016 at 7:23

1 Answer 1

7

This will need you to modify values based on your GRIDCODE as I can only see 4 and 16 in your table, but to do this in the Field Calculator is fairly straightforward.

In the Field Calculator window, select Python parser, and select Show Codeblock. Enter the following into the Pre-Logic Script Code textbox:

def updateName(gCode):
 if gCode == 4:
 name = 'Vegetation'
 elif gCode == 8:
 name = 'Sand Fill'
 elif gCode == 12:
 name = 'Water Body'
 elif gCode == 16:
 name = 'Built-up Area'
 else:
 name = None
 return name

And then in the NAME = expression box enter

updateName( !GRIDCODE! )

You will need to modify the GRIDCODE values in the script to match the values in your field, and then modify the names to match the corresponding NAME value.

enter image description here

enter image description here

answered Jun 16, 2016 at 7:46
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.