<div dir="ltr">Hi Anita,<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Oct 5, 2014 at 9:45 AM, Anita Graser <span dir="ltr"><<a href="mailto:anitagraser@gmx.at" target="_blank">anitagraser@gmx.at</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I'm trying to use one of the examples from the PyQGIS Cookbook to render a map at custom resolution:<br>
<br>
<a href="http://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/composer.html#simple-rendering" target="_blank">http://docs.qgis.org/testing/<u></u>en/docs/pyqgis_developer_<u></u>cookbook/composer.html#simple-<u></u>rendering</a><br>
<br>
While the layers render fine, no labels are drawn. Do you know how I can add labels to the output?<br>
<br>
I tried<br>
<br>
render.setLabelingEngine(<u></u>QgsPalLabeling())<br>
<br>
but no luck.<br></blockquote><div><br></div><div>Here's a small script you can use to test the Python bindings for labeling [0]. It is intended to be run from within the PyQGIS console's script editor, and uses the Spatialite db for labeling unit tests, called '<span class="">pal_features_v3.sqlite'</span> [1].<br><br></div><div>Setup:<br><br></div><div>* Load the 'background' layer<br>* Load the 'point' layer on top of 'background'<br>* Select the 'point' layer in the legend<br>* Open script in console's editor and run it<br><br>When script is run, you should end up with something like this [2], probably with different fill color for 'background'.<br></div><div><br></div><div>See the Python labeling test suite for more examples, from 'test_qgspallabeling_*.py' [3], specifically the 'test_qgspallabeling_tests.py' file.<br><br></div><div>Feel free to add this to the Cookbook. However, the API for labeling may change during the 2.7 dev cycle, if rule- and style-based labeling is introduced.<br></div><div><br>[0] <a href="https://gist.github.com/dakcarto/33115cd569e17b9419c0">https://gist.github.com/dakcarto/33115cd569e17b9419c0</a><br>[1] <a href="https://github.com/qgis/QGIS/tree/master/tests/testdata/labeling">https://github.com/qgis/QGIS/tree/master/tests/testdata/labeling</a><br>[2] <a href="http://drive.dakotacarto.com/qgis/labeling_py-api.png">http://drive.dakotacarto.com/qgis/labeling_py-api.png</a><br>[3] <a href="https://github.com/qgis/QGIS/tree/master/tests/src/python">https://github.com/qgis/QGIS/tree/master/tests/src/python</a><br><br></div><div>Regards,<br></div><div><br>Larry Shaffer<br>Dakota Cartography<br>Black Hills, South Dakota<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Thanks and best wishes,<br>
Anita<span class=""><font color="#888888"><br>
<br>
<br>
-- <br>
<a href="http://anitagraser.com" target="_blank">anitagraser.com</a><br>
______________________________<u></u>_________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/qgis-<u></u>developer</a><br>
</font></span></blockquote></div><br></div></div></div>