Saturday 18 February 2017

qgis - How to zoom to the extent of a Qgsvectolayer using PyQGIS?



Anyone know how to zoom to the extent of a Vectorlayer in QGIS using python plugin?



Answer



You'd get the app's Map Canvas and set its extent.


canvas = qgis.utils.iface.mapCanvas()
canvas.setExtent(layer.extent())

You might want to read this tutorial.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...