2

i want to label a point layer with those values exceeding a set of variables

attribute table as follows

'loc field'(text),'a'(float),'b'(float),'c'(float)

variables as follows

vara = 5, varb = 3, varc=1

basically i want to be able to label 'a' > vara, 'b' > varb, 'c' > varc on a multi-line label, needs to label if any are true not just all three e.g

Loc: F23
a: 6

('b' was 2 so not labelled)

c: 1.5

If none are true then loc not labelled at all

I am thinking this will be best achieved using the expression based label with a python function but don't know how to go about it, as i haven't found any documentation that deals directly with this. Could someone point me in the right direction on how to write a function that takes in each field to be queried and returns the multi-line label.

Cheers

closed as unclear what you're asking by underdark Dec 25 '14 at 23:55

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Labeling your point layer based on an expression built only with the Field Calculator functions would be useful for you? Or you are looking for a solely, pure Python solution? – Sorin Călinică Feb 12 '14 at 9:44
0

Here is a function I used recently setting an expression based label on a layer.

def setupLabels(self):
        layerMatr = QgsMapLayerRegistry.instance().mapLayersByName(LOOKUP_TABLE_MATR)[0]
        palyr = QgsPalLayerSettings()
        palyr.readFromLayer(layerMatr)

        #self.log('palyr.getLabelExpression().dump(): %s' % palyr.getLabelExpression().dump())

        palyr.fieldName = 'CASE WHEN \"MATRNR\" != \'%s\' THEN \'Matr. nr. \' || MATRNR END' % self.Ifu.Matrnr
        palyr.writeToLayer(layerMatr)
        self.iface.mapCanvas().refresh()

        #self.log('palyr.getLabelExpression().dump(): %s' % palyr.getLabelExpression().dump())
  • Cheers Jakob i'll have a play around with it – Pat Feb 12 '14 at 22:28

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