I'm trying to answer my own question asked here, but which has not found favour: In QGIS save a view like a bookmark based on center and scale
I thought I might be able to work backwards, by defining screen center (centre) and screen scale, then working backwards to get the geographic extents. Note I'm a Python novice and have never tackled PyQGIS before.
Screen centre turned out to be trivial (so long as points were in correct units for the CRS):
canvas = qgis.utils.iface.mapCanvas() center = QgsPointXY(44, 42) canvas.setCenter(center)
I naively thought I could do a similar trick with setScale, but this gives the error 'QgsMapCanvas' object has no attribute 'setScale' no matter what I try.
I know I can change the display scale using lines like this:
However, this changes the scale by changing the window extent, which is not what I want. How can I do this?