[Qgis-user] (no subject)

Asim al-sofi asim56 at gmail.com
Sat Oct 26 05:40:08 PDT 2024


Hi all
Iam trying to make a print layout using a defined rectangle.
The print layout created using the rectangle is correct in the x
coordinates but in the y coordinates it is always smaller than the defined
rectangle.
*The code snippet is:*
layout = QgsPrintLayout(project)
layoutName = "PrintLayout"
#initializes default settings for blank print layout canvas
layout.initializeDefaults()
layout.setName(layoutName)
manager.addLayout(layout)
map = QgsLayoutItemMap(layout)
map.setRect(20, 20, 20, 20)
#defines map extent using map coordinates
rectangle =
QgsRectangle(float(bounds[0]),float(bounds[1]),float(bounds[2]),float(bounds[3]))#
x min y min, x max y max
rectangle =
QgsRectangle(QgsPointXY(float(bounds[0]),float(bounds[1])),QgsPointXY(float(bounds[2]),float(bounds[3])))#
x min y min, x max y max
map.setExtent(rectangle)
layout.addLayoutItem(map)
#Move & Resize map on print layout canvas
map.attemptMove(QgsLayoutPoint(0, 0, QgsUnitTypes.LayoutMillimeters))
map.attemptResize(QgsLayoutSize(297, 210, QgsUnitTypes.LayoutMillimeters))

Any ideas what is wrong with my code?
Thanks in advance
Kind regards,
Asim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20241026/99df3e6e/attachment-0001.htm>


More information about the QGIS-User mailing list