管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-11-05 fce62ac82dfa89cb4d3accfde3c32b6f7caf9943
1
已修改2个文件
17 ■■■■■ 文件已修改
QGIS/render.py 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QGIS/说明.txt 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
QGIS/render.py
@@ -6,12 +6,14 @@
from qgis.PyQt.QtWidgets import *
from qgis.PyQt.QtXml import *
def finished():
    img = render.renderedImage()
    # QgsProject.instance().homePath()
    image_location = os.path.join("e:/", "render.png")
    # save the image; e.g. img.save("/Users/myuser/render.png","png")
    img.save(image_location, "png")
QgsApplication.setPrefixPath("C:/Program Files/QGIS 3.16/bin", True)
qgs = QgsApplication([], True)
@@ -33,8 +35,8 @@
doc = QDomDocument()
doc.setContent(template_content)
# doc = QDomDocument("E:/data/1.Natural_Earth/Layout.qpt")
#ele = layout.writeXml(doc, QgsReadWriteContext())
#layout.readLayoutXml(ele, doc, QgsReadWriteContext())
# ele = layout.writeXml(doc, QgsReadWriteContext())
# layout.readLayoutXml(ele, doc, QgsReadWriteContext())
layout.loadFromTemplate(doc, QgsReadWriteContext(), False)
map = QgsLayoutItemMap(layout)
@@ -46,17 +48,17 @@
# page.setPageSize('A4')
# collection.addPage(page)
layoutView = QgsLayoutView()
layoutView.setPreviewModeEnabled(True)
layoutView.setContentsMargins(0, 0, 0, 0)
layoutView.setCurrentLayout(layout)
# layoutView = QgsLayoutView()
# layoutView.setPreviewModeEnabled(True)
# layoutView.setContentsMargins(0, 0, 0, 0)
# layoutView.setCurrentLayout(layout)
# project.layoutManager().addLayout(layout)
# map = QgsLayoutItemMap(layout)
# map.zoomToExtent(iface.mapCanvas().extent())
exporter = QgsLayoutExporter(layout)
img_path = os.path.join("e:/", "render.png")
img_path = os.path.join("E:/terrait/TianJin/LFServer/QGIS", "render.png")
exporter.exportToImage(img_path, QgsLayoutExporter.ImageExportSettings())
qgs.exitQgis()
QGIS/˵Ã÷.txt
@@ -35,6 +35,7 @@
================================================================================
https://blog.csdn.net/qq_23034515/article/details/107643428
https://vimsky.com/examples/detail/python-ex-qgis.core-QgsPrintLayout-itemByUuid-method.html # ReadWriteXml
https://vimsky.com/zh-tw/examples/detail/python-ex-qgis.core-QgsLayoutFrame-setId-method.html # Python QgsLayoutFrame.setId
1.搭建QGIS+Python开发环境
2.承德高新区指挥平台,将和对讲集成到主站点(http协议)下
3.qgis python二次开发