3

I'm developing a maximum flow plugin for QGIS. I would like to show a calculation result (i.e., the maximum flow) on the map. The result is not a property of a single feature. It is a property of a whole layer. What is the best way to accomplish this?

7
  • 1
    Can you please supply more information such as what is this 'calculation result', what code you have developed so far etc?
    – Joseph
    Aug 13, 2014 at 9:18
  • @Joseph I revised my question.
    – wannik
    Aug 15, 2014 at 0:24
  • @wannik it would help if you could share further information on where you're stuck, what you've tried, etc. At the moment the question is still very vague. Aug 15, 2014 at 1:00
  • Where do you need to show the information? On the map canvas, a dock/dialog of your plugin or in a map composer? Aug 15, 2014 at 11:53
  • @MatthiasKuhn I'd like to show a string on a map canvas (if possible). A user can see it all the time no matter the position or zoom level.
    – wannik
    Aug 20, 2014 at 1:59

1 Answer 1

2

There are two things you will need to do in python in order to solve this problem

Calculating the values

There is no support for aggregate expressions in QGIS, so you will have to resort to implementing your own logic with python.

You can do the following:

  • Use QgsVectorLayer.maximumValue( fieldIndex ) if you just need the maximum value of a given field.
  • Write your logic in python and connect it to the appropriate signals to be recalculated. QgsVectorLayer.attributeValueChanged(fid, idx, value) is a good candidate for you.

Drawing on the map

You can refer to this previous answer about how to add a new item to the map canvas. Just adapt the paint method to print a string instead of the bar.

https://gis.stackexchange.com/a/69844/9839

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.