I want to zoom into the current active QGIS canvas from a standalone python script.

I tried the following but it doesn't impact the current QGIS canvas:

import qgis.utils
canvas = qgis.utils.iface.mapCanvas()

Can I modify the QGIS app from a standalone python script (not from the QGIS Python console)? If so, how do I do that?

  • Purely a guess but perhaps try using from qgis.gui import QgsMapCanvas?
    – Joseph
    Jan 20, 2015 at 11:21
  • Doesn't do anything either.
    – ustroetz
    Jan 20, 2015 at 12:32
  • what kind of standalone script? Something that inside a QGIS session?
    – Nathan W
    Jan 20, 2015 at 12:53
  • I have a running QGIS session and independently from that a Python script (not the Python console).
    – ustroetz
    Jan 20, 2015 at 12:56
  • 1
    Very similar question: gis.stackexchange.com/questions/77797/… Jan 24, 2015 at 4:14


Your Answer

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

Browse other questions tagged or ask your own question.