Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to create some custom labels for point features in a QGIS point vector layer, and I want to write a python plugin to do it. We need our labels to be presented with color tinted rectangles behind them (or else!). The labels are long strings, and are created using labeling engine expressions and conditionals. I thought the easiest way would be to let the user set up labels for the active layer the way they want, and then let my plugin can grab the label text from the features in the layer and use the text strings to create boxes. My problem is I can't find a way to access those text strings in the QGIS API. How are label strings generated by the labeling engine stored in QGIS and how can I get to them?

Thanks,

Mushroom

share|improve this question
1  
By labels do you mean the labels for the individual point features? – R.K. Dec 22 '12 at 8:38
Yes. And I want it done at the layer level, not at the print composer level. I tried automatically generating text callout boxes because I didn't realize they were print composer features, and that was really ugly. – MonsterMushroom Dec 27 '12 at 9:44
1  
Have you thought about a strong buffer colour behind the text? I did that on one job. On another I just told the client it was not an option.... It seems a common request.... – Willy Dec 28 '12 at 23:58
1  
The strong color buffer is my current solution. However, the client had the boxes (using a script) in their ArcGIS implementation, and they want to see the same thing in QGIS. (We're trying to change systems.) My current answer is that this is not an option, but that is never a fun answer, and I would really like to pull something out of my pocket. Plus, boxes around labels should be something we can do. It just makes sense. – MonsterMushroom Dec 30 '12 at 12:58
I think the answer to this is going to be that once the labels are generated by the labeling engine and rendered to the map canvas, they are saved as svg vectors, and not as strings and are thus irretrievable. I saw this on a blog but I have not yet been able to (had the time to) confirm it, so that is not an official answer. (Also, I have learned that shield labels are being worked on as an add for the much anticipated 2.0) – MonsterMushroom Feb 5 at 20:14

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.