In QGIS I'd like to add scale to my PyQGIS image exporter.
Similar to the Project -> Import/Export -> Export map to image
where you can add the scale to the image as in the picture below.
vLayer = QgsProject.instance().mapLayersByName("a_g")[0]
sExtent=vLayer.extent()
sOutputDpi= 300
sZoomScale = 2500
sQSize=QSize(10000, 10000)
settings = QgsMapSettings()
settings.setOutputSize(sQSize)
settings.setExtent(sExtent)
settings.outputDpi = sOutputDpi
settings.scale = sZoomScale
render = QgsMapRendererParallelJob(settings)
def finished():
img = render.renderedImage()
img.save(image_location, "png")
render.finished.connect(finished)
render.start()
In the output I'd like to include the scale of the map as well. At the moment the image exporter exports the image scaleless (I think) and only takes note of the setExtent
value.
Does anyone know if it's possible to include scale in this script?