[Qgis-developer] PyQGIS : QgsMapRender does not project layers
rldhont
rldhont at gmail.com
Thu Oct 3 08:32:06 PDT 2013
Hi all,
I encounter some difficulties with QGIS 2.
I have some code which rendering well layers in a PNg image, but now it
does not project layers :
# create renderer
render = QgsMapRenderer()
# set output size
render.setOutputSize(img.size(), img.logicalDpiX())
outputCrs = QgsCoordinateReferenceSystem(3857,
QgsCoordinateReferenceSystem.EpsgCrsId)
render.setDestinationCrs(outputCrs)
render.setProjectionsEnabled( True )
# set map units to get labels from new label engine
render.setMapUnits(outputCrs.mapUnits())
render.setOutputUnits(QgsMapRenderer.Millimeters)
render.updateScale()
labeling = QgsPalLabeling()
render.setLabelingEngine(labeling)
p = QPainter()
p.begin(self.img)
p.setRenderHint(QPainter.Antialiasing)
render.setLayerSet(lst)
render.setExtent(rect)
# do the rendering
render.render(self.p)
# end
p.end()
What I missed ?
René-Luc D'Hont
3Liz
More information about the Qgis-developer
mailing list