[Qgis-developer] Select all elements in the view ...

Nathan Woodrow madmanwoo at gmail.com
Thu Oct 24 03:21:03 PDT 2013


Hey Roberto,

No need for all that :)

This is all you need:

rq = QgsFeatureRequest(iface.mapCanvas().extent())
for feature in layer.getFeatures(rq):
   ...

http://www.qgis.org/api/classQgsFeatureRequest.html

- Nathan



On Thu, Oct 24, 2013 at 8:11 PM, Geo DrinX <geodrinx at gmail.com> wrote:

> Hello all again,
>
> From PyQgis, I need to export (to my own format) only the elements
> contained in the QGis view.
>
> So, I taken the canvas coordinates and I created a string that has the
> "expression" syntax:
>
>                 text = self.iface.mapCanvas().extent().toString()
>                 text1 = text.replace("," , " ")
>                 text2 = text1.replace(" : ", ",")
>                 text = "bbox($geometry, geomFromWKT ( 'LINESTRING(" +
> text2 + ")'))"
>
>
> There is a way to applicate the bbox filter during the scanning of the
> elements, that is during:
>
>                     iter = layer.getFeatures()
>                     for feat in iter:
>
> ...or, need I to filter elements from myself ?
>
> It will be only in 2.2 version ?
>
> Thank you for any info about this
>
> Roberto
>
>
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20131024/1c62ca30/attachment.html>


More information about the Qgis-developer mailing list