3

I am trying to put the north arrow on the graphic output of the map using PyQGIS (QGIS 3.4). I tried adding it as an image with the attached code but I have the background of the image and it does not fit. Would there be any other way?

north = QgsLayoutItemPicture(layout)
north.setPicturePath("C:/Users/Pc/Desktop/logo.png")
layout.addLayoutItem(north)
north.attemptResize(QgsLayoutSize(23, 23,gsUnitTypes.LayoutMillimeters))
north.attemptMove(QgsLayoutPoint(3,234,QgsUnitTypes.LayoutMillimeters)) 
0

1 Answer 1

2

Rather than using a .png image, use a .svg file with a transparent background.

north = QgsLayoutItemPicture(layout)
north.setPicturePath("C:/Users/Pc/Desktop/logo.svg")
layout.addLayoutItem(north)
north.attemptResize(QgsLayoutSize(23, 23,gsUnitTypes.LayoutMillimeters))
north.attemptMove(QgsLayoutPoint(3,234,QgsUnitTypes.LayoutMillimeters)) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.