[QGIS-Developer] Iterate over layer features in a model - get_feature_by_id

Nyall Dawson nyall.dawson at gmail.com
Mon May 11 18:20:59 PDT 2020


On Tue, 12 May 2020 at 11:08, Pedro VenĂ¢ncio <pedrongvenancio at gmail.com> wrote:
>
> Hi all,
>

>
> However, I was trying to give a more generic use to the model, and so I added the 'Add geometry attributes' algorithm to it. With this, I cannot get the coordinates anymore with the expression:
>
> concat(attributes( get_feature_by_id(@Add_geometry_attributes_OUTPUT, 0))['xcoord'], ',', attributes( get_feature_by_id(@Add_geometry_attributes_OUTPUT, 0))['ycoord'])
>

> This can be due to the fact that the intermediate result of 'Add geometry attributes' is a memory layer? Is there any possibility of doing this in another way?

No -- it's a limitation in models, that expressions CANNOT access
layers which have been created during the model execution. Only layers
present in the project at the start of the model execution can
(currently) be utilised by expressions in a model.

The fix is not trivial -- e.g. for myself I'd budget about 3 days to fix this.

Nyall


More information about the QGIS-Developer mailing list