<div dir="ltr"><div>Thanks a lot Johannes, very appreciated,</div><div>diving directly into your links.</div><div><br></div><div>Best,</div><div>Andrea</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Apr 12, 2023 at 10:13 AM Johannes Kröger (WhereGroup) <<a href="mailto:johannes.kroeger@wheregroup.com">johannes.kroeger@wheregroup.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <p>Hey Andrea,</p>
    <p>you can do it *if* your data source (or rather the provider that
      QGIS uses for your data source) supports spatial queries for the
      provider feature filtering.<br>
    </p>
    <p>Our "Räumlicher Filter" plugin does exactly that using
      setSubsetString :))</p>
    <ul>
      <li><a href="https://github.com/WhereGroup/spatial_filter" target="_blank">https://github.com/WhereGroup/spatial_filter</a></li>
      <li><a href="https://plugins.qgis.org/plugins/spatial_filter/" target="_blank">https://plugins.qgis.org/plugins/spatial_filter/</a><br>
      </li>
    </ul>
    <p>Try it and look at the resulting filter queries or check how we
      construct the filter strings:<br>
    </p>
    <ul>
      <li><a href="https://github.com/WhereGroup/spatial_filter/blob/e77abb9830f5d46073239b8e7376c52a69046223/filters.py#L14" target="_blank">https://github.com/WhereGroup/spatial_filter/blob/e77abb9830f5d46073239b8e7376c52a69046223/filters.py#L14</a><br>
      </li>
      <li><a href="https://github.com/WhereGroup/spatial_filter/blob/e77abb9830f5d46073239b8e7376c52a69046223/filters.py#L45" target="_blank">https://github.com/WhereGroup/spatial_filter/blob/e77abb9830f5d46073239b8e7376c52a69046223/filters.py#L45</a></li>
    </ul>
    <p>As of now, the plugin supports it for PostGIS, GPKG and
      Spatialite layers . It probably is easy to adapt for other
      geospatial databases too.<br>
    </p>
    <p>Cheers, Hannes<br>
    </p>
    <div>Am 12.04.23 um 09:35 schrieb andrea
      antonello via QGIS-User:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">Hello,
        <div>I was wondering if in pyqgis there is a way to load a layer
          to show only features that intersect a certain geometry. I see
          the setSubsetString for sql like queries, but no way to do
          this with geometries.</div>
        <div><br>
        </div>
        <div>Similar to this (but only applied to iterations using
          getFeatures), I was wondering if with QgsFeatureRequest and
          expressions there is a way to create a geometry intersection
          filter (I saw the setFilterRect). </div>
        <div><br>
        </div>
        <div>Thanks a lot for any hint,</div>
        <div>Andrea</div>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
QGIS-User mailing list
<a href="mailto:QGIS-User@lists.osgeo.org" target="_blank">QGIS-User@lists.osgeo.org</a>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
</pre>
    </blockquote>
    <pre cols="72">-- 
Johannes Kröger / GIS-Entwickler/-Berater

---------------------------------------------
Aufwind durch Wissen!
Web-Seminare und Online-Schulungen
bei der <a href="http://www.foss-academy.com" target="_blank">www.foss-academy.com</a>
---------------------------------------------

WhereGroup GmbH
c/o KK03 GmbH
Lange Reihe 29
20099 Hamburg
Germany

Tel: +49 (0)228 / 90 90 38 - 36
Fax: +49 (0)228 / 90 90 38 - 11

<a href="mailto:johannes.kroeger@wheregroup.com" target="_blank">johannes.kroeger@wheregroup.com</a>
<a href="http://www.wheregroup.com" target="_blank">www.wheregroup.com</a>
Geschäftsführer:
Olaf Knopp, Peter Stamm 
Amtsgericht Bonn, HRB 9885
-------------------------------
</pre>
  </div>

</blockquote></div></div>