1

I basically have the same question as: How to quickly calculate bounding box coordinates of a selected polygon with QGIS. However I am building a stand alone application in python and so do not have the iFace class. I can get to the extent class easily enough with :

box = layer2.extent()
OR box = self.map_canvas.extent()

Which gives me an object that claims it is an extent, but how do I get the coordinates out?

underdark
  • 84,148
  • 21
  • 231
  • 413
AnserGIS
  • 1,068
  • 7
  • 19
  • 1
    I know it must be simple, thanks! I'm confused though, ".xMinimum" didn't show up as an intellisense option? p.s. if you move this to an answer i can close the question. – AnserGIS May 19 '16 at 13:01
  • Most welcome! Not sure about it popping up as an option for a stand-alone application (haven't made one myself yet) but you could always ask it as a new question =) – Joseph May 19 '16 at 13:06

1 Answers1

1

You could use something like the following to get the coordinates of your extent:

xmin = layer2.extent().xMinimum()
xmax = layer2.extent().xMaximum()
ymin = layer2.extent().yMinimum()
ymax = layer2.extent().yMaximum()
Joseph
  • 75,746
  • 7
  • 171
  • 282