10

I've asked a similar question here: How to quickly calculate bounding box coordinates of a selected polygon with qgis

...regarding a quick way to determine the bounding box of a given layer.

Is there any way to do the same thing for the current qgis view? I imagine it is an iface property but cannot find it in the documentation. Thanks.

update: I'm working with the qgis print (map) creator right now, and I've found a button which appears to call a function that I'm alluding to. If you open the print creator, in the right side bar there is a menu button called "Item Properties". Click on this and below there is a submenu called "Extents". Expand that and there is a button called "Set to map canvas extent". This button appears to utilize the function I'm alluding to by extracting the bbox coords of the main qgis map view.

boulder_ruby
  • 1,824
  • 4
  • 27
  • 43

1 Answers1

23

This will return you the extent of the canvas.

extent = iface.mapCanvas().extent()

Reference: http://qgis.org/api/classQgsMapCanvas.html#a878f0c387c9475d59c6aac425db01020

Nathan W
  • 34,706
  • 5
  • 97
  • 148