On Wed, 11 Sep 2019 at 08:06, G. Allegri <[email protected]> wrote:
>
> Dear all,
> I was confident that it would have been simple, while I can’t find the proper
> way od doing that. Having a reference to a QgsVectorLayer, I would need to
> use a subset of its features to run an algorithm down the line.
> I hoped there was a way to define an input as afeature source with a filter
> (QgsFeatureRequest or similar. I’ve tried using
> QgsProcessingFeatureSourceDefinition with a selection but with no luck:
>
> pointlayer.selectByRect(rect, QgsVectorLayer.SetSelection)
>
> processing.run("qgis:voronoipolygons", {
> 'INPUT': QgsProcessingFeatureSourceDefinition(
> pointlayer.id(),
> True),
> 'BUFFER': 10,
> 'OUTPUT': outpath})
>
> error, can’t find the layer with that id, since it expects to find it in the
> proje
>
> Any ideas? Is it possible to build a QgsProcessingParameterDefinition for the
> task?
It depends if you can get away with a layer subset string for the
filter. (I.e. provider side filter). Because if so, you can embed
these filters in layer sources, e.g.
processing.run("native:centroids",
{'INPUT':'/home/me/layer.shp|layerid=0|subset=\"something\" =
\'value\'','ALL_PARTS':False,'OUTPUT':'TEMPORARY_OUTPUT'})
Would be nice to extend QgsProcessingFeatureSourceDefinition to
support an expression based filter, that sounds like a good
addition...
Nyall
_______________________________________________
QGIS-Developer mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer