Select to view content in your preferred language

ModelBuilder - automatic rename attributes in table based on shape area

777
1
12-05-2021 10:34 AM
Labels (3)
StanislavaV
Emerging Contributor

Hi guys,

I was wondering if it is possible to rename my polygons based on shape area. 

I am using this exact advice from mr. Pike https://community.esri.com/t5/arcmap-questions/modelbuilder-automatic-rename-attributes-in-table/m-p...

but I am thinking if we can rename them like this - when I have polygons with CODE 2000, then CODE 2 would be calculated based on shape area - the biggest would be for CODE2 the same as it was original - in this case 1, smaller would be CODE2 2, the smallest would be CODE3 ... and so on...

 

From this

FID      CODE        CODE2       AREA

1           1001              2                0,5

2           1001              2                 1

3            2000             1                 0,25

4            2000             1                   1,5

5            2000            1                    0,75

 

To this

FID      CODE        CODE2       AREA

1           1001              3                0,5

2           1001              2                  1

3            2000             3                  0,25

4            2000             1                   1,5

5            2000            2                    0,75

0 Kudos
1 Reply
curtvprice
MVP Esteemed Contributor

The easiest way to do this in ModelBuilder is to use the Sort tool to sort by CODE and Shape_Area and then write a python function in Calculate Field tool with a code block with a function that assigns values according to your rules as you navigate through the sorted table. 

Or, take what I bet is @DanPatterson's advice and do this in Python/numpy in a Calculate Value function that reads the table, sorts it and does your logic.

I do not follow your logic here. 

0 Kudos