Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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) ?
share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

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
share|improve this answer
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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