Hi,
Ok I looked at the Statistic by categories. I thought it operated on two
vector files (something like zonal statistics). I now see it's on a
single vector file and it's fields so my advice was not great. I'am not
quite sure I follow you on why you need to combine field names from 2
files but I few months ago, I had difficulty passing an input string as
a field with that name. I solved the problem using this
"(attribute(to_string( @NamelengthField ))" (Thanks Nyall). This was
Nyall's explanation:
"There's no bug here -- the variable value is just a pure text string,
and the expression engine can't automatically guess that you actually
want the value of the field with that name, and not just the name string
itself. Hence the need for the attribute function, which allows you to
retrieve a feature's fields via a text string containing the field name."
Using that idea (the attribute() function), I was able to combine 2 text
strings into a "field" recognized by the model. Hope this helps? If it
does not, send us a simplified model of the problem. Maybe we can look
at it.
Nicolas
On 2022-01-26 11:51 a.m., Simon Dietmann wrote:
Hi Nicolas,
thank you for your quick reply. I am not sure if I understand
correctly what you are suggesting, because the ‘join by attribute’ and
‘aggregate’ functions both will change the attributes of the vector
layer.
What I´m trying to do instead is to give a list of field names as a
parameter to the function ‘statistics by categories’, and my problem
is that I don´t have this single list, but two separate lists that
each contain a part of these field names. So I would like to merge the
two lists of field names and pass it over to the algorithm, but I have
no idea how to do this.
Another solution could be to perform the ‘union’ first, and only
afterwards ask the user to specify the field names for evaluation.
Unfortunately, I have no idea either how to determine a chronological
sequence where the ‘vector field’ input is queried after the ‘union’
has already been performed.
Thank you very much for your help,
Simon
*Von:*Nicolas Cadieux <[email protected]>
*Gesendet:* Mittwoch, 26. Januar 2022 17:21
*An:* Simon Dietmann <[email protected]>; [email protected]
*Betreff:* Re: [Qgis-user] model builder - merge several inputs
Hi,
You could try a "join attribute by location" followed by a "Aggregate"...
Nicolas
On 2022-01-26 3:43 a.m., Simon Dietmann wrote:
Dear list,
I am trying to find a solution for the following problem with the
model builder:
My model asks for two vector polygon layers that will be combined
by ‘union’. The resulting layer gets a new field (field
calculator) and is evaluated by ‘Statistics by categories’
algorithm. The fields for the categories are selected by the user
when calling the model. Since those fields are present in the two
separate input layers, I have to use two separate ‘Vector field’
inputs.
The problem arises when I try to combine those two input variables
to use them together for the ‘Statistics by categories’ algorithm.
AFAICS there is no function inside the model builder to achieve
this, so I suggest I have to export the model as a python script.
There I found that the call of the Statistics function gives the
name of the variable as a parameter and not the variable itself:
alg_params = {
'CATEGORIES_FIELD_NAME': parameters['fields'], ….
How can I combine my two lists (~like
“parameters[‘fields’+’fields2’], or is there a way to do this
inside the model builder that I didn´t find?
Thanks in advance for help, kind regards
Simon Dietmann
Mit freundlichen Grüßen
im Auftrag
Simon Dietmann
M.Sc. Physische Geografie
Aufgrund der aktuellen Situation bin ich zur Zeit vermehrt im Home
Office tätig und dort erreichbar unter +49 69 – 57 80 56 98 oder
per Email, ich rufe Sie dann gerne zurück.
PGNU Planungsgesellschaft Natur & Umwelt mbH
Amtsgericht Frankfurt am Main, HRB 111938
Geschäftsführer: Dr. Benjamin Hill, Johannes Christoph Kress,
Alexander von Küchler
Hamburger Allee 45 +++ D-60486 Frankfurt am Main
Durchwahl: +49 (69) 95 29 64 - 75 +++ Fax: +49 (69) 95 29 64 – 99
E-Mail: [email protected] <mailto:[email protected]> +++ Web:
www.pgnu.de <http://www.pgnu.de/>
> Diese E-Mail könnte vertrauliche und/oder rechtlich geschützte
Informationen enthalten. Wenn Sie nicht der richtige Adressat sind
oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte
sofort den Absender und vernichten Sie diese Mail. Das unerlaubte
Kopieren sowie die unbefugte Weitergabe dieser Mail sind nicht
gestattet.
> This e-mail may contain confidential and/or privileged information. If
you are not the intended
recipient (or have received this e-mail in error) please notify
the sender immediately and destroy this e-mail. Any unauthorized
copying, disclosure or distribution of the material in this e-mail
is strictly forbidden.
_______________________________________________
Qgis-user mailing list
[email protected]
List info:https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe:https://lists.osgeo.org/mailman/listinfo/qgis-user
--
Nicolas Cadieux
https://gitlab.com/njacadieux
--
Nicolas Cadieux
https://gitlab.com/njacadieux
_______________________________________________
Qgis-user mailing list
[email protected]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user