<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,</p>
<font face="Helvetica, Arial, sans-serif">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:</font><br>
<p><font face="Helvetica, Arial, sans-serif">"</font><font
face="Helvetica, Arial, sans-serif">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."</font><br>
</p>
<p><font face="Helvetica, Arial, sans-serif">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.<br>
</font></p>
<p><font face="Helvetica, Arial, sans-serif">Nicolas<br>
</font></p>
<br>
<div class="moz-cite-prefix">On 2022-01-26 11:51 a.m., Simon
Dietmann wrote:<br>
</div>
<blockquote type="cite"
cite="mid:45cb44bb-46ea-499a-a1a7-814aa27db66f@pgnu.de">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]-->
<style>@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}pre
{mso-style-priority:99;
mso-style-link:"HTML Vorformatiert Zchn";
margin:0cm;
font-size:10.0pt;
font-family:"Courier New";
mso-fareast-language:DE;}span.HTMLVorformatiertZchn
{mso-style-name:"HTML Vorformatiert Zchn";
mso-style-priority:99;
mso-style-link:"HTML Vorformatiert";
font-family:Consolas;
mso-fareast-language:EN-US;}span.E-MailFormatvorlage22
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}div.WordSection1
{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Hi Nicolas,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="EN-GB">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. <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">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.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Thank you very much for
your help, <o:p></o:p></span></p>
<div>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif;mso-fareast-language:DE"
lang="EN-GB"><br>
<br>
</span><span
style="font-size:10.0pt;font-family:"Arial",sans-serif;mso-fareast-language:DE">Simon
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
</div>
<div>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span
style="mso-fareast-language:DE">Von:</span></b><span
style="mso-fareast-language:DE"> Nicolas Cadieux
<a class="moz-txt-link-rfc2396E" href="mailto:njacadieux.gitlab@gmail.com"><njacadieux.gitlab@gmail.com></a> <br>
<b>Gesendet:</b> Mittwoch, 26. Januar 2022 17:21<br>
<b>An:</b> Simon Dietmann
<a class="moz-txt-link-rfc2396E" href="mailto:simon.dietmann@pgnu.de"><simon.dietmann@pgnu.de></a>;
<a class="moz-txt-link-abbreviated" href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a><br>
<b>Betreff:</b> Re: [Qgis-user] model builder - merge
several inputs<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Hi,<span style="mso-fareast-language:DE"><o:p></o:p></span></p>
<p>You could try a "join attribute by location" followed by a
"Aggregate"...<o:p></o:p></p>
<p>Nicolas<o:p></o:p></p>
<div>
<p class="MsoNormal">On 2022-01-26 3:43 a.m., Simon Dietmann
wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-GB">Dear list,</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">I am trying to find a
solution for the following problem with the model builder:</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">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.</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">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:</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">alg_params = {</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">
'CATEGORIES_FIELD_NAME': parameters['fields'], ….</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">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?</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB">Thanks in advance for
help, kind regards</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="MsoNormal">Simon Dietmann<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif;mso-fareast-language:DE"><br>
<br>
Mit freundlichen Grüßen<br>
im Auftrag</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size:10.0pt;font-family:"Arial",sans-serif;mso-fareast-language:DE"><br>
Simon Dietmann<br>
</span><span
style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#999999;mso-fareast-language:DE">M.Sc.
Physische Geografie</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#999999;mso-fareast-language:DE"> </span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#999999;mso-fareast-language:DE">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.<br>
<br>
</span><span style="mso-fareast-language:DE"><img
style="width:2.1083in;height:.9083in" id="Bild_x0020_1"
src="cid:part1.Unr3nSWn.RwniUnyP@gmail.com" class=""
width="202" height="87"></span><span
style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#999999;mso-fareast-language:DE"><br>
<br>
<br>
</span><o:p></o:p></p>
<p class="MsoNormal"><span
style="font-size:9.0pt;font-family:"Arial",sans-serif;color:#999999;mso-fareast-language:DE">PGNU
Planungsgesellschaft Natur & Umwelt mbH<br>
Amtsgericht Frankfurt am Main, HRB 111938<br>
Geschäftsführer: Dr. Benjamin Hill, Johannes Christoph
Kress, Alexander von Küchler<br>
Hamburger Allee 45 +++ D-60486 Frankfurt am Main<br>
Durchwahl: +49 (69) 95 29 64 - 75 +++ Fax: +49 (69) 95 29
64 – 99<br>
E-Mail: <a href="mailto:dietmann@pgnu.de"
moz-do-not-send="true"><span style="color:#999999">dietmann@pgnu.de</span></a>
+++ Web: <a href="http://www.pgnu.de/"
moz-do-not-send="true"><span style="color:#999999">www.pgnu.de</span></a></span><span
style="font-size:10.0pt;font-family:"Arial",sans-serif;color:#999999;mso-fareast-language:DE"><br>
<br>
</span><span
style="font-size:8.0pt;font-family:"Arial",sans-serif;color:#999999;mso-fareast-language: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.<br>
</span><span
style="font-size:8.0pt;font-family:"Arial",sans-serif;color:#999999;mso-fareast-language:DE"
lang="EN-GB">> 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.</span><o:p></o:p></p>
<p class="MsoNormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="MsoNormal"><span style="mso-fareast-language:DE"><br>
<br>
<o:p></o:p></span></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>Qgis-user mailing list<o:p></o:p></pre>
<pre><a href="mailto:Qgis-user@lists.osgeo.org" moz-do-not-send="true" class="moz-txt-link-freetext">Qgis-user@lists.osgeo.org</a><o:p></o:p></pre>
<pre>List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true" class="moz-txt-link-freetext">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></pre>
<pre>Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" moz-do-not-send="true" class="moz-txt-link-freetext">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></pre>
</blockquote>
<pre>-- <o:p></o:p></pre>
<pre>Nicolas Cadieux<o:p></o:p></pre>
<pre><a href="https://gitlab.com/njacadieux" moz-do-not-send="true" class="moz-txt-link-freetext">https://gitlab.com/njacadieux</a><o:p></o:p></pre>
</div>
</blockquote>
<pre class="moz-signature" cols="72">--
Nicolas Cadieux
<a class="moz-txt-link-freetext" href="https://gitlab.com/njacadieux">https://gitlab.com/njacadieux</a></pre>
</body>
</html>