[QGIS-Developer] QGIS3 - processing python script. Read features from output layer
kimaidou
kimaidou at gmail.com
Thu Feb 15 22:29:10 PST 2018
Thanks Nyall,
Our posts crossed !
Ok for the shortcut and the getMapLayer method.
One question : in my alg, if I use QgsProcessingParameterFeatureSource
instead of QgsProcessingParameterVectorLayer for my input, can I still use
mapLayerFromString and the getFeatures, or is there a
featureSourceFromString which allows me to loop through the features ?
Michaƫl
2018-02-16 7:22 GMT+01:00 Nyall Dawson <nyall.dawson at gmail.com>:
> On 16 February 2018 at 04:36, kimaidou <kimaidou at gmail.com> wrote:
> > Hi all,
> >
> > I have a simple processing python alg which
> > * generates a buffer with qgis:buffer
> > * use qgis:fieldcalculator to add an buf_area field -> the output vector
> of
> > my alg is this buffer+new field.
> >
> > I would like to parse the features of the output vector in order to
> gather
> > some information and put it in a new string output. I have not been able
> to
> > get the layer object to perform a getFeatures on it.
> >
> > See the code
> > http://paste.debian.net/1010463/
> >
> > In line 32, my blayer is None
> > I think I am not using the good way to get the output vector layer
> features?
> > I tried to use the same way as for reading an input layer, but oviously
> it
> > is different.
>
> blayer = QgsProcessingUtils.mapLayerFromString( area_result[ 'OUTPUT'
> ]), context )
>
> I'm thinking of adding a shortcut for this to the context, e.g.:
>
> blayer = context.getMapLayer( area_result['OUTPUT'] )
>
> What do you think?
>
> Nyall
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20180216/aabbc0bd/attachment.html>
More information about the QGIS-Developer
mailing list