'Why can't i use Qgs map canvas on qgs processing script?
Thank you already for taking the time to read this. I am writing an qgs Python processing script, the result of this script is a formated pdf. In one of the steps i need set qgs map canvas to my shapefile extension, but the qgs map canvas are not working, what is the difference on this context from an standalone script, for instance? This is how i am trying set qgs map canvas:
# Reference to map Canvas
canvas = QgsMapCanvas()
# allow anti aliasing
canvas.enableAntiAliasing(flag=True)
# canvas color
canvas.setCanvasColor(Qt.white)
# canvas extension
canvas.setExtent(fieldlayer.extent())
# set canvas layer
canvas.setLayers([fieldlayer])
In this context, i cant not start qgs application through the usual command lines because the script would crash:
# Start qgs
os.environ["QT_QPA_PLATFORM"] = "offscreen"
QgsApplication.setPrefixPath("/usr", True)
qgs = QgsApplication([], False)
qgs.initQgis()
### qgs manipulation here ###
# Exit qgs
qgs.exitQgis()
The Whole script can be found here:
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
