Skip to main content
added link, grammer
Source Link
LaughU
  • 4.2k
  • 5
  • 23
  • 42

this is simpel in pyqgis:

layer = iface.activeLayer() # is the currently selctedselected layer
box = layer.boundingBoxOfSelected() # creates a bounding box
iface.mapCanvas().setExtent(box) # zooms to this boundinboxbounding box

you could also scale the box variable with

box.scale(2,box.center()[0], box.center()[1])

where "2" is the scale factor.

testedTested with QGIS 2.18. For further research have a look athe pyqgis api of boundingBoxOfSelected

this is simpel in pyqgis:

layer = iface.activeLayer() # is the currently selcted layer
box = layer.boundingBoxOfSelected() # creates a bounding box
iface.mapCanvas().setExtent(box) # zooms to this boundinbox

you could also scale the box variable with

box.scale(2,box.center()[0], box.center()[1])

where "2" is the scale factor.

tested with QGIS 2.18

this is simpel in pyqgis:

layer = iface.activeLayer() # is the currently selected layer
box = layer.boundingBoxOfSelected() # creates a bounding box
iface.mapCanvas().setExtent(box) # zooms to this bounding box

you could also scale the box variable with

box.scale(2,box.center()[0], box.center()[1])

where "2" is the scale factor.

Tested with QGIS 2.18. For further research have a look athe pyqgis api of boundingBoxOfSelected

Source Link
LaughU
  • 4.2k
  • 5
  • 23
  • 42

this is simpel in pyqgis:

layer = iface.activeLayer() # is the currently selcted layer
box = layer.boundingBoxOfSelected() # creates a bounding box
iface.mapCanvas().setExtent(box) # zooms to this boundinbox

you could also scale the box variable with

box.scale(2,box.center()[0], box.center()[1])

where "2" is the scale factor.

tested with QGIS 2.18