[Qgis-user] QgsLayoutExporter and Raster Layers
Eric Younkin - NOAA Federal
eric.g.younkin at noaa.gov
Tue Mar 8 10:53:14 PST 2022
Hello,
I am using the QgsLayoutExporter to build a screenshot of my QgsMapCanvas
view, following the code in the Quick Print plugin (
https://github.com/MarcoDuiker/QGIS_QuickPrint/blob/d1c946a7b6187553c92ffad7a0cc23d39a1bc593/quick_print3.py
).
I build the QgsLayoutItemMap as follows (including only relevant lines):
map = qgis_core.QgsLayoutItemMap(layout)
...
mylayers = self.project.mapThemeCollection().masterVisibleLayers()
map.setLayers(mylayers)
...
layout.addLayoutItem(map)
...
exporter = qgis_core.QgsLayoutExporter(layout)
exporter.exportToImage(fil,
qgis_core.QgsLayoutExporter.ImageExportSettings())
mylayers correctly lists the layers that I have loaded in my application.
[<QgsRasterLayer:
'/vsimem/tj_patch_test_710_20220224_150745_depth_1_8.0.tif' (gdal)>,
<QgsVectorLayer: '0015_20200317_094852_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0014_20200317_093221_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0013_20200317_091555_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0012_20200317_090126_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0011_20200317_084855_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0010_20200317_083654_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0009_20200317_082551_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0008_20200317_081048_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0007_20200317_075822_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0006_20200317_074548_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0005_20200317_072016_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0004_20200317_071004_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0003_20200317_065753_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0002_20200317_064945_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0001_20200317_063913_S222_EM710.all' (ogr)>,
<QgsVectorLayer: '0000_20200317_062845_S222_EM710.all' (ogr)>,
<QgsRasterLayer: 'type=xyz&url=
https://a.tile.openstreetmap.org/%7Bz%7D/%7Bx%7D/%7By%7D.png&zmax=19&zmin=0&crs=EPSG:4326'
(wms)>]
Each of these layers correctly shows in the screenshot, with the exception
of the first one, the vsimem based raster layer. This layer shows in my app
in the canvas, but is missing from the screenshot. I have tried exporting
that layer by itself, messing with renderers and opacity, etc. I can't seem
to get the vsimem raster layer to show in the screenshot. I thought the WMS
raster layer was going to be an issue, but it shows just fine.
Is there any issue with vsimem gdal layers? Should this layer work, if I
can visualize it on the canvas in my app? I can't figure out where to go
next to diagnose this issue.
Thanks, Eric
--
Eric Younkin
Physical Scientist
NOAA OCS, Hydrographic Systems and Technology Branch
1315 East-West Highway
N/CS11, Room 6604
Silver Spring, MD 20910
Office: 240-847-8208
Cell: 828-331-8197
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220308/7cc9c375/attachment.html>
More information about the Qgis-user
mailing list