Skip to content

Instantly share code, notes, and snippets.

@NathanW2
Last active October 22, 2015 22:59
Show Gist options
  • Save NathanW2/547db77ed63f3c64a3a4 to your computer and use it in GitHub Desktop.
Save NathanW2/547db77ed63f3c64a3a4 to your computer and use it in GitHub Desktop.
from qgis.core import *
from qgis.gui import *
@qgsfunction(args=-1, group='Custom')
def max_name(fields, feature, parent):
realindex = [feature.fieldNameIndex(field) for field in fields]
values = [feature[field] for field in fields]
index = values.index(max(values))
index = realindex[index]
return feature.fields()[index].name()
@NathanW2
Copy link
Author

Usage

 max_name( 'Tree_id', 'centX', 'centY')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment