<div dir="ltr"><div class="gmail_extra"><br>Grazie Luigi per l'esempio fornito,</div><div class="gmail_extra">Quindi da quello che hai riportato nell'esempio da una parte ho la mia lista di shp (<span style="font-size:12.8000001907349px">extent = vl.extent</span>) che deve essere confrontata con un extent di controllo ovvero <span style="font-size:12.8000001907349px">geomExtentDiControllo. Il mio problema è che non so come accedere alle proprietà geometriche di quest'ultimo.</span></div><div class="gmail_extra"><span style="font-size:12.8000001907349px"><br></span></div><div class="gmail_extra"><span style="font-size:12.8000001907349px">Ho provato così</span></div><br>folder = 'S:\\Dati_geografici_RP\\I.6_Particelle catastali\\Catastale'<br>lista_folder = (os.listdir(folder))<br><b>geomExtentDiControllo = QgsGeometry.fromRect(QgsRectangle (xmin =442882.70,ymin = 5015200.28,xmax =487902.38,ymax =5087429.92))<br></b><br>for sub_folder in lista_folder:<br>    new_folder = folder+'\\'+sub_folder<br>    lista_shp =  (os.listdir(new_folder)) <br>    <br>    for shp in lista_shp:<br>        if string.find(shp,'PARTICELLA.shp') >=0:<br>            vl = QgsVectorLayer(shp, "mioshape", "ogr")<br>            extent = vl.extent()<br>            geomExtent = QgsGeometry.fromRect(extent)<br>            isInside = geomExtent.within(geomExtentDiControllo)<br>            if isInside:<br>                QgsMapLayerRegistri.instance().addMapLayer(vl)<div><br></div><div>In grassetto la parte che mi è ancora lacunosa infatti il programma finisce senza restituire nulla!</div><div><br></div><div>Sto usando come riferimento questo perchè sono ancora alle prime armi come si può capire!</div><div><a href="http://www.padido.eu/gfoss/qgis/workshop/workshop/esplorare/python_in_qgis_tutorial2.html">http://www.padido.eu/gfoss/qgis/workshop/workshop/esplorare/python_in_qgis_tutorial2.html</a><br></div><div><br></div><div><div class="gmail_extra"><i><font color="#0b5394"><span style="font-size:12.8000001907349px"><br></span></font></i></div><div class="gmail_extra"><span style="color:rgb(80,0,80);font-size:12.8000001907349px"><br></span></div><div class="gmail_extra"><span style="color:rgb(80,0,80);font-size:12.8000001907349px"><br></span></div><div class="gmail_extra"><span style="color:rgb(80,0,80);font-size:12.8000001907349px">2015-03-06 </span><span style="font-size:12.8000001907349px">11:10</span><span style="color:rgb(80,0,80);font-size:12.8000001907349px"> GMT+01:00 </span><font color="#20124d"><i><span style="font-size:12.8000001907349px">Luigi Pirelli</span></i><span style="font-size:12.8000001907349px"> </span><span style="font-size:12.8000001907349px"><</span><span style="font-size:12.8000001907349px"><a href="mailto:luipir@gmail.com">luipir@gmail.com</a></span><span style="font-size:12.8000001907349px">>:</span><i><span style="font-size:12.8000001907349px"><br></span></i></font></div><div class="gmail_extra"><i><span style="font-size:12.8000001907349px"><font color="#20124d"><br></font></span></i></div><div class="gmail_extra"><i><font color="#20124d"><span style="font-size:12.8000001907349px">senza scomodare gdal e rimanendo in pyqgis</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">1) carichi il layer in memoria (senza visualizzarlo)</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">vl = QgsVectorLayer(shp, "mioshape", "ogr")</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">2) prendi l'extent del vettore</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">extent = vl.extent()</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">come vedrai extent e' un QgsRectangle =></span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">3) ho bisogno di un QgsGeometry per usarne gli operatori spaziali</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">geomExtent = QgsGeometry.fromRect(extent)</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">4) alla stessa cosa per generarti la geometria dell'extent che vuoi contollare</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">geomExtentDiControllo = QgsGeometry.fromRect(...un qgis rectangle... )</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">ti consiglio di vederti:  </span><a href="http://qgis.org/api/classQgsGeometry.html" target="_blank" style="font-size:12.8000001907349px">http://qgis.org/api/classQgsGeometry.html</a><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">per costruirti il QgsREctangle di controllo</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">5) usi l'operatore di QgsGeometry che meglio ti si addice</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">isInside = geomExtent.within(</span><span style="font-size:12.8000001907349px">geomExtentDiControllo)</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">oppure</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">isInside = geomExtent.intersects(</span><span style="font-size:12.8000001907349px">geomExtentDiControllo)</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">if isInside:</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">    QgsMapLayerRegistri.instance()</span><span style="font-size:12.8000001907349px">.addMapLayer(vl)</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">ciao Luigi Pirelli</span></font></i><br></div></div></div>