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?

2
  • 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
    Commented May 19, 2016 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
    Commented May 19, 2016 at 13:06

1 Answer 1

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()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.