Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Basically, I am trying to sort the records within the shapefile based on an attribute(eg: pop) and then add a new field that indicates ranking based on the sort. eg: the record with the highest pop would get a rank value of 1, the next would get a value 2.

I can easily sort and add the field in arcgis but the calculating field so that it is ranked based on the order is something i don't know how it works and hence i am thinking may be a python script would be better.

Any help or thoughts on this would be greatly appreciated.

share|improve this question

Assuming you're using ArcGIS 10 (I'd have to check if it works in 9.3) you could use an update cursor, which has a sort attribute.

pop_rank = 1
rows = arcpy.UpdateCursor ("path_to_dataset", "", "", "", "pop A")
for row in rows:
    row.setValue("pop_rank_field", pop_rank)
    pop_rank += 1

The A after the sort field name means ascending, which you could replace with D for descending also.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.