2

I know how to obtain various statistics for a field, or "column", in an attribute table in ArcGIS. Is there any way to obtain a Mode figure for records, or the "rows" in a table? For instance, an attribute table of plots of land might contain 15 fields each showing the number of a particular type of tree on each plot. I need to find out, for a particular plot, what type of tree is the most common there. What is the easiest way to find out which of the 15 fields has the highest figure for that record? Am I right that the answer somehow involves the Field Calculator?

0

you are right that you can use the field calculator, but you could also do this with a cursor. With the field calculator, you can define a function that take all your fields as input and gives the position of the field as an output.

argmax(!field1!,!field2!,!field3!,...,!field15!)


def argmax(a,b,c,...o):
    mylist = [a,b,c,...o]
    return mylist.index(max(mylist))

The same function can be used with a cursor, but then you have the advantage of being ble to list the fields automatically (listFields) and to get the name of the field instead of the number of the field.

  • Thanks! I've found how to do this, and am having a different sort of problem, but that'll be another question. – Mhoram Jun 22 '16 at 3:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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