GIS and Media fusion

"The explosive growth of the GeoWeb and geographic information has made GIS powerful media for the general public to communicate, but perhaps more importantly, GIS have also become media for constructive dialogs and interactions about social issues." - Sui & Goodchild

User Tools

Site Tools


geoinf14:qgsmaprenderer

QgsMapRenderer

from PyQt4.QtGui import *
from PyQt4.QtCore import *

#begin
img = QImage(QSize(800,600), QImage.Format_ARGB32_Premultiplied)
img.fill(QColor(255,255,255).rgb())

p = QPainter()
p.begin(img)
p.setRenderHint(QPainter.Antialiasing)

render = QgsMapRenderer()

aLayer = qgis.utils.iface.activeLayer()
#aLayer.loadSldStyle('/tmp/test.sld')
render.setLayerSet([ aLayer.id() ])

rect = QgsRectangle(render.fullExtent())
render.setExtent(rect)
render.setOutputSize(img.size(), 96)

render.render(p)
p.end()
img.save("/tmp/render.png","png")
#end
geoinf14/qgsmaprenderer.txt · Last modified: 2018/05/16 10:05 (external edit)