TransWikia.com

How to fill a field with the ranking of another field for a shapefile attribute table in ArcGIS Pro?

Geographic Information Systems Asked by titi on April 6, 2021

I want to add a field ("FreqRank") in my attribute table with the rank of the field "COUNT", so it was sorted descendingly (see below).

enter image description here

I tried the code here from another post below (https://community.esri.com/thread/213033-code-field-based-on-rank-of-another-field), but it just give me the OBJECTID.

#Codeblock:

rank = 0
lastValue = None

def getNextRank(value):
  global rank
  global lastValue
  if value == lastValue:
    return rank
  else:
    rank += 1
    lastValue =value
    return rank

One Answer

You can use this link to sort your table permanently and use the code above as @Khibma suggests.

Or, This could be done easily with using cursor and ArcPy

if you dont have ArcPy experience, you can extract the attribute table by table to excel tool

insert your rankings and join that table back to attribute table by using ObjectID as common field

Answered by Amadeus on April 6, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP