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 ?
1 Answer 1
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.
Explore related questions
See similar questions with these tags.