Select to view content in your preferred language

How to fill in selected fields with same number

1665
1
10-24-2022 02:23 PM
JessMcClelland
New Contributor

I have an attribute table of 8k plus items. I have made a new field(Buffer) and in that field I want Red be 10, Blue be 20 and Yellow be 30 in that field. I am trying to eventually use the Buffer tool to buffer them by these amounts.

I have followed the steps of this post over here: https://gis.stackexchange.com/questions/230636/buffer-different-distances-based-on-field-values

On how to select each type(color) by attribute and then you're supposed to use Calculate Field to fill in the values, but I can't seem to make the selected fields populate the numbers I want. Typing in 10 in the Expression area does nothing. I get no errors, but the selected fields remain 0. I've tried "10" but that results in an error.

UPDATE: It seems like it was working, but for whatever reason ArcGIS Pro was not updating the rows visible without scrolling, so it looked nothing was happening. Why it would torture me like this, I have no idea.

I've uploaded a screenshot just in case this happens to anyone else and they think they're going crazy.

I'm not trying to do any math or equations or add fields together, I am just trying to fill these specific rows with the same number. How do you get fields(or selections) to populate a number all at once instead of typing them in manually one by one?

Thank you for any help! This is for my final project and it's the only thing I can't figure out and it seems like it's going to be so obvious, it's absolutely killing me.

0 Kudos
1 Reply
AlfredBaldenweck
MVP Regular Contributor

Simple way: Select by Attribute, then field calculate for each attribute like you were doing before. First the Yellows, then the Blues, etc.

Less Simple but 1 step: Field Calculator (Python)

AlfredBaldenweck_0-1666707600103.png

def buffDist(field1):
    ''' Create Dictionary and pass the values through it'''
    bDist = {"Yellow":"40", "Blue": "50", "Red": "60"}
    return bDist[field1]
    '''Alternatively, you can spell it out like this, but that's more
        more work for you.
    '''
    #if field1 == "Yellow":
    #    return "10"
    #elif field1 == "Blue":
    #    return "20"
    #elif field1 == "Red":
    #    return "30"
    
  1. Paste the expression into the codeblock
  2.  Then call it in calculation field with buffDist(whateveryourfieldis)
0 Kudos