<html><head></head><body><a href="http://www.qgis.org/api/classQgsFeatureRequest.html#ac7c734b9cab6939a706ea53040afe6b3">http://www.qgis.org/api/classQgsFeatureRequest.html#ac7c734b9cab6939a706ea53040afe6b3</a><br>
<br>
that might help<br><br><div class="gmail_quote">On January 12, 2017 5:20:07 PM GMT+01:00, Tom Chadwin <tom.chadwin@nnpa.org.uk> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">I've found this method:<br /><br />viewportPolygon =<br />QgsGeometry().fromWkt(iface.mapCanvas().extent().asWktPolygon())<br />layer = iface.activeLayer()<br /><br />resultlayer = QgsVectorLayer("Polygon", "result", "memory")<br />resultlayer.dataProvider().addAttributes(list(layer.dataProvider().fields()))<br /><br />clippedFeatures = []<br />for feature in layer.dataProvider().getFeatures():<br />    clippedGeometry = feature.geometry().intersection(viewportPolygon)<br /><br /><br />From <a href="http://gis.stackexchange.com/a/74471/36921">http://gis.stackexchange.com/a/74471/36921</a><br /><br />However, this loops through all features. I'm concerned that this will<br />struggle with large layers. Is there a more efficient method?<br /><br /><br /><br />-----<br />Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon <br />--<br />View this message in context: <a href="http://osgeo-org.1560.x6.nabble.com/Create-memory-layer-containing-only-features-visible-in-current-canvas-extent-tp5303218p5303223.html">http://osgeo-org.1560.x6.nabble.com/Create-memory-layer-containing-only-features-visible-in-current-canvas-extent-tp5303218p5303223.html</a><br />Sent from the Quantum GIS - Developer mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br /><hr /><br />Qgis-developer mailing list<br />Qgis-developer@lists.osgeo.org<br />List info: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br />Unsubscribe: <a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a></pre></blockquote></div><br>
-- <br>
Sent from my Android device with K-9 Mail. Please excuse my brevity.</body></html>