Hi QGIS devs, <br><br>could someone please give this thread's code a try?<br><br>I've already attempted several things with no success, namely to store layers (vlayer), features, geometries and/or rubber bands in a list. Still I'm unable to get the geometries displayed as rubber bands, is it possible with QGIS? <br>

<br>I'm using QGIS 
1.8.0-Lisboa, rev. a1255fc, Python v.2.7.2, GDAL/OGR v.1.7.3<br><br>Thanks in advance, <br><br>Germán<br><br><br><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Germán Carrillo</b> <span dir="ltr"><<a href="mailto:carrillo.german@gmail.com">carrillo.german@gmail.com</a>></span><br>

Date: 2012/5/21<br>Subject: Displaying local file's geometries as rubber bands<br>To: qgis-developer <<a href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>><br><br><br>Hi all, <br><br>

I'd like to get geometries from a local file (e.g. GML) displayed as QgsRubberBands. However, I wouldn't like to load the layer into the map because in the real scenario there could be a large number of files to get geometries from. <br>


<br>I've been attempting it with the following code (you can copy it directly to the QGIS Python Console), but only the last feature is displayed:<br><br>#---------------------------------------------------------------------------------------------------------<br>


from qgis.core import QgsFeature, QgsVectorLayer<br>from qgis.gui import QgsRubberBand<br><br>def loadGMLAsRubberBands(fileName):<br>    featList = []    <br>    rb = QgsRubberBand(qgis.utils.iface.mapCanvas(), True)<br>

    <br>
    vlayer = QgsVectorLayer(fileName, "layer", "ogr")<br>    allAttrs = vlayer.dataProvider().attributeIndexes()<br>    vlayer.select(allAttrs)         <br>    f = QgsFeature()<br>    <br>    while vlayer.dataProvider().nextFeature(f):<br>


        featList.append(f)           <br>        rb.addGeometry(featList[-1].geometry(), None)    <br><br>loadGMLAsRubberBands("/tmp/gml/sample_three_features.gml")<br>#---------------------------------------------------------------------------------------------------------<br>


<br>Based on the solution given in this thread [1] I'm storing the features in a list, but somehow it doesn't work in this scenario. A sample GML file can be found at [2].<br><br>Do you have any hint?<br><br><br>

Regards, <br>
<br>Germán<br><br>-------------------<br>[1] <a href="http://lists.osgeo.org/pipermail/qgis-developer/2012-May/020143.html" target="_blank">http://lists.osgeo.org/pipermail/qgis-developer/2012-May/020143.html</a><br clear="all">

[2] <a href="http://ifgibox.de/g_carr02/sample_three_features.gml" target="_blank">http://ifgibox.de/g_carr02/sample_three_features.gml</a><span class="HOEnZb"><font color="#888888"><br>
<br>-- <br>-----------<br>   |\__  <br>(:>__)(<br>   |/    <br><br>Soluciones Geoinformáticas Libres                            <br><a href="http://geotux.tuxfamily.org/" target="_blank">http://geotux.tuxfamily.org/</a><br>

<a href="http://twitter.com/GeoTux2" target="_blank">http://twitter.com/GeoTux2</a><br>
<br>
</font></span></div><br>-- <br>-----------<br>   |\__  <br>(:>__)(<br>   |/    <br><br>Soluciones Geoinformáticas Libres                            <br><a href="http://geotux.tuxfamily.org/">http://geotux.tuxfamily.org/</a><br>

<a href="http://twitter.com/GeoTux2">http://twitter.com/GeoTux2</a><br><br>