""" Define new functions using @qgsfunction. feature and parent must always be the last args. Use args=-1 to pass a list of values as arguments """ from qgis.core import * from qgis.gui import * @qgsfunction(args='auto', group='Custom') def azimuth(x1,y1,x2,y2, feature, parent): p1 = QgsPoint(x1,y1) p2 = QgsPoint(x2,y2) a = p1.azimuth(p2) if a < 0: a += 360 return a