I am using canvas method for extend polygon in center in QGIS but i want to make polygon in center with increases border width. i am trying to below code but polygon can not set in center and increase polygon border width.
from PyQt4.QtCore import *from PyQt4.QtGui import *from qgis.core import *from qgis.utils import *import shapefilesf = shapefile.Reader("K:\NEW_GIS\NEW GIS DATA\Bhojpur Dur\SHP FILE\Bhojpurdur_Corrected.shp")shapes = sf.shapes()canvas = iface.mapCanvas()layer = iface.activeLayer()iter = layer.getFeatures()for feature in iter: feature.id() print feature['chalta_No'] shape_area=shapes[feature.id()].bbox zoomRectangle = QgsRectangle(shape_area[0],shape_area[1],shape_area[2],shape_area[3]) canvas.setExtent(zoomRectangle) mapRenderer = iface.mapCanvas().mapRenderer() c = QgsComposition(mapRenderer) c.setPlotStyle(QgsComposition.Print) x, y = 0, 0 w, h = c.paperWidth(), c.paperHeight() composerMap = QgsComposerMap(c, x,y,w,h) print composerMap c.addItem(composerMap) item = QgsComposerScaleBar(c) item.setStyle('Numeric') # optionally modify the style item.setComposerMap(composerMap) item.applyDefaultSize() c.addItem(item) dpi = c.printResolution() dpmm = dpi / 25.4 width = int(dpmm * c.paperWidth()) height = int(dpmm * c.paperHeight()) # create output image and initialize it image = QImage(QSize(width, height), QImage.Format_ARGB32) image.setDotsPerMeterX(dpmm * 1000) image.setDotsPerMeterY(dpmm * 1000) image.fill(0) # render the composition imagePainter = QPainter(image) sourceArea = QRectF(0, 0, c.paperWidth(), c.paperHeight()) targetArea = QRectF(0, 0, width, height) c.render(imagePainter, targetArea, sourceArea) imagePainter.end() image.save("C:/example/C/%s.png" % feature['chalta_No'],"png") canvas.refresh()i want to like below image.
أكثر...
from PyQt4.QtCore import *from PyQt4.QtGui import *from qgis.core import *from qgis.utils import *import shapefilesf = shapefile.Reader("K:\NEW_GIS\NEW GIS DATA\Bhojpur Dur\SHP FILE\Bhojpurdur_Corrected.shp")shapes = sf.shapes()canvas = iface.mapCanvas()layer = iface.activeLayer()iter = layer.getFeatures()for feature in iter: feature.id() print feature['chalta_No'] shape_area=shapes[feature.id()].bbox zoomRectangle = QgsRectangle(shape_area[0],shape_area[1],shape_area[2],shape_area[3]) canvas.setExtent(zoomRectangle) mapRenderer = iface.mapCanvas().mapRenderer() c = QgsComposition(mapRenderer) c.setPlotStyle(QgsComposition.Print) x, y = 0, 0 w, h = c.paperWidth(), c.paperHeight() composerMap = QgsComposerMap(c, x,y,w,h) print composerMap c.addItem(composerMap) item = QgsComposerScaleBar(c) item.setStyle('Numeric') # optionally modify the style item.setComposerMap(composerMap) item.applyDefaultSize() c.addItem(item) dpi = c.printResolution() dpmm = dpi / 25.4 width = int(dpmm * c.paperWidth()) height = int(dpmm * c.paperHeight()) # create output image and initialize it image = QImage(QSize(width, height), QImage.Format_ARGB32) image.setDotsPerMeterX(dpmm * 1000) image.setDotsPerMeterY(dpmm * 1000) image.fill(0) # render the composition imagePainter = QPainter(image) sourceArea = QRectF(0, 0, c.paperWidth(), c.paperHeight()) targetArea = QRectF(0, 0, width, height) c.render(imagePainter, targetArea, sourceArea) imagePainter.end() image.save("C:/example/C/%s.png" % feature['chalta_No'],"png") canvas.refresh()i want to like below image.

أكثر...