1

I'm trying to produce a map with different categories based on four columns (lag, mlag, mhog and hog), these are income status. I want each polygon in the map to be represented by whatever number who is the highest among these four columns, thus making it a map with four different categories that represent the most prevalent income in that area.

I.e. for FID 0 it will be 'hog'

I figure it must be something related to Symbology but there is no option to select categories based upon highest number or something like it.

I hope I was clear enough, the task is quite simple I think but I can't really see right now how I should do it.

enter image description here

3
  • Do you want a map of four categories or for example a map that show the actual highest number?
    – Bera
    Commented Mar 21, 2017 at 9:53
  • 1
    Oh, I should've mentioned it. I want a map with four categories separated by colour. But defined by the highest number of these four columns.
    – Mutumba
    Commented Mar 21, 2017 at 9:54
  • Please edit the question in response to requests for clarification.
    – Vince
    Commented Mar 21, 2017 at 10:54

1 Answer 1

2

Script below will add a new field called highestcat and fill with name of the highest category. You can then use this field to set the symbology:

import arcpy,operator
fc=r'C:\TEST.gdb\polygons' #change to match your data
arcpy.AddField_management(in_table=fc, field_name='highestcat', field_type='TEXT',field_length=10)
fieldlist=['lag','mlag','mhog','hog','highestcat']
with arcpy.da.UpdateCursor(fc,fieldlist) as cursor:
    for row in cursor:
        index, value = max(enumerate(row[:4]), key=operator.itemgetter(1))
        row[4]=fieldlist[index]
        cursor.updateRow(row)

enter image description here

1
  • 1
    This solved my problem, thank you very much for writing this script for me!
    – Mutumba
    Commented Mar 21, 2017 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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