6

i am just wondering if it is possible to iterate through vector features and return the extent per feature without clipping the vector shape?

The code looks like this and comes from the PyQgis-Documentation. How can i return the extent of every vector feature in a loop.

provider = vector.dataProvider()
            feat = QgsFeature()
            allAttrs = provider.attributeIndexes()
            provider.select(allAttrs)
            while provider.nextFeature(feat):
                geom = feat.geometry()
                # --> return extent or (xmin,ymin,xmax,ymax) ?
9

how about...

provider = vector.dataProvider()
        feat = QgsFeature()
        allAttrs = provider.attributeIndexes()
        provider.select(allAttrs)
        while provider.nextFeature(feat):
            geom = feat.geometry()
            rect = geom.boundingBox()  #get bounding box as QgsRectangle
  • 2
    damn, pretty obvious. thanks. just for info: It returns a QRectangle object which can be queried with Xminimum and so on – Curlew Oct 10 '12 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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