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 '15 at 11:21
  • Doesn't do anything either. – ustroetz Jan 20 '15 at 12:32
  • what kind of standalone script? Something that inside a QGIS session? – Nathan W Jan 20 '15 at 12:53
  • I have a running QGIS session and independently from that a Python script (not the Python console). – ustroetz Jan 20 '15 at 12:56
  • 1
    Very similar question: gis.stackexchange.com/questions/77797/… – Germán Carrillo Jan 24 '15 at 4:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.