QGIS导出作曲家在python中为pdf
我有一个包含作曲家的QGIS项目。当然,如果进入GUI,我可以将其导出为pdf等。对于我的make脚本,尽管我想通过python脚本来完成。通过在线阅读,这是我的尝试: #!/usr/bin/env python import sys from qgis.gui import QgsMapCanvas, QgsLayerTreeMapCanvasBridge from PyQt4.QtCore import QFileInfo from PyQt4.QtXml import QDomDocument from qgis.core import * qgs = QgsApplication(sys.argv, True) QgsApplication.setPrefixPath("/usr", True) qgs.initQgis() def make_pdf(): canvas = QgsMapCanvas() bridge = QgsLayerTreeMapCanvasBridge( QgsProject.instance().layerTreeRoot(), canvas) bridge.setCanvasLayers() QgsProject.instance().read(QFileInfo('../board.qgs')) composition = QgsComposition(canvas.mapSettings()) map_item = composition.getComposerItemById('board36x48') map_item.setMapCanvas(canvas) map_item.zoomToExtent(canvas.extent()) composition.refreshItems() …