[QGIS-Developer] QGIS processing model: extract specific attribute of a single feature to a string

Nyall Dawson nyall.dawson at gmail.com
Tue Aug 11 16:13:39 PDT 2020


On Tue, 11 Aug 2020 at 18:48, Andreas Neumann <a.neumann at carto.net> wrote:
>
> Hi Ujaval,
>
> Thanks for the "hacky" idea ;-)
>
> I am happy to report that it worked for me.
>
> For the long run, it would be good to have an algorithm to extract a string from an attribute of a selected feature (something like attribute(get_feature(expression_to_get_feature),attribute) ) or at least an "Expression Executor" that outputs a string. Expressions can do a lot, but getting a string output from an Expression seems to be impossible.

This is true -- a number of expressions which work fine in QGIS itself
fail in the modeler. Specifically, any which reference layers directly
which have been created as a result of previous steps in the model
won't work (aggregates, get_feature, etc). Would be good to resolve
this at some stage, but it's not a 5 minute fix (closer to 0.5-1 day).

Given this, I think a simple "get attribute for first feature"
algorithm for use in models could be useful...

Nyall





>
> Anyway, I can progress now with the rest of my model.
>
> Thanks again,
>
> Andreas
>
> On 2020-08-11 10:15, Ujaval Gandhi wrote:
>
> I can think of a slightly hacky way. Use the 'Basic Statistics for Field' algorithm, and since your field will have a single value, use either the Minimum or Maximum value output from it (works for string fields too) as the parameter for another algorithm.
>
> Ujaval Gandhi
> Spatial Thoughts
> mobile: +91-8095684687
> email: ujaval at spatialthoughts.com
>
> Subscribe to our newsletter http://bit.ly/spatialthoughts-newsletter
>
> On Tue, Aug 11, 2020 at 1:23 PM Andreas Neumann <a.neumann at carto.net> wrote:
>
> Hi,
>
> In a model I aggregate values to a single feature. Then I would like to extract a specific aggregated attribute to a string so I can use it as the input parameter of another algorithm.
>
> I fail to find a way to do that. Aggregation works fine, string concatenation as well, but I fail to find a way to extract an attribute of a single feature to a string.
>
> Any ideas?
>
> I'm on QGIS 3.10, but if necessary I could also use a newer QGIS version.
>
> Thanks,
>
> Andreas
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the QGIS-Developer mailing list