<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<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 class="moz-txt-link-freetext" href="https://github.com/WhereGroup/spatial_filter">https://github.com/WhereGroup/spatial_filter</a></li>
<li><a class="moz-txt-link-freetext" href="https://plugins.qgis.org/plugins/spatial_filter/">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 class="moz-txt-link-freetext" href="https://github.com/WhereGroup/spatial_filter/blob/e77abb9830f5d46073239b8e7376c52a69046223/filters.py#L14">https://github.com/WhereGroup/spatial_filter/blob/e77abb9830f5d46073239b8e7376c52a69046223/filters.py#L14</a><br>
</li>
<li><a class="moz-txt-link-freetext" href="https://github.com/WhereGroup/spatial_filter/blob/e77abb9830f5d46073239b8e7376c52a69046223/filters.py#L45">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 class="moz-cite-prefix">Am 12.04.23 um 09:35 schrieb andrea
antonello via QGIS-User:<br>
</div>
<blockquote type="cite"
cite="mid:CACck5jOpGSRrTAOTAZL3bUUjr0O9kL4YdMsDj3EaXrh7Le3CjA@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<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 class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
QGIS-User mailing list
<a class="moz-txt-link-abbreviated" href="mailto:QGIS-User@lists.osgeo.org">QGIS-User@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
Johannes Kröger / GIS-Entwickler/-Berater
---------------------------------------------
Aufwind durch Wissen!
Web-Seminare und Online-Schulungen
bei der <a class="moz-txt-link-abbreviated" href="http://www.foss-academy.com">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 class="moz-txt-link-abbreviated" href="mailto:johannes.kroeger@wheregroup.com">johannes.kroeger@wheregroup.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.wheregroup.com">www.wheregroup.com</a>
Geschäftsführer:
Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRB 9885
-------------------------------
</pre>
</body>
</html>