5

I'm working with QGIS 3.2 Bonn and try to set up a workflow with the graphic modeler.

The model uses the Intersection Tool from the QGIS Geoprocessing Tools. The model works, but I don't want to keep all fields from the intersection process.

In this case, the tool provides the possibility to set "Input fields to keep" from the input feature layer and "Intersect fields to keep" from the intersect feature layer. I was able to define just one field to keep, but in case of several fields to keep in the output, I couldn't find any solution yet.

I tried different syntax possibilities:

  • [attributefield1, attributefield2, ...]
  • ["attributfield1", "attributefield2",...]
  • "attributefield1", "attributefield2", ...
  • 'attributefield1', 'attributefield1',...

In the QGIS online-manual I found only this information:

Input fields to keep [tablefield: any] [list]
Optional
Choose here the field(s) of the input layer to be kept. If no fields are chosen all fields are taken.

https://docs.qgis.org/testing/en/docs/user_manual/processing_algs/qgis/vectoroverlay.html#intersection

How do I set the list of fields there?

Screenshot:

4
  • Did you try ['attribute1', 'attribute2', ...]? If that doesn't work, here's a workaround: run intersection with the default setting of "keep all fields." Add a step to your model, remove unwanted fields with the drop field(s) algorithm. – csk Sep 1 '18 at 17:35
  • Yeah i tried this version ['attribute1', 'attribute2',...] before. It doesn't work for me. I also tried your suggested workaround with the drop field(s) algorithm, but there i get the same problem. I don't get the syntax right for more than one attribute field. With just one field, it works without brackets and without any quotation marks, just the name of the attribute in the input line. But with more than one field, it doesn't work with or without marks or brackets. Or do i have to define the fields-to-keep in the intersection or drop-process by an additional input-variable? – L.Blanc Sep 1 '18 at 18:42
  • If you define a Vector Field input, you can select that field from the drop down menu. I have two field inputs designed, field1 and field2. When I type field1, field2, it allows me to click OK without giving me an error. I haven't fully tested that the tool runs as expected, though. – csk Sep 1 '18 at 22:47
  • Hi @csk, thanks for your help! I tried your suggestion with the vector field input. I really would appreciate this solution because the model would become more userfriendly by this for other people. Unfortunately i also don't get it done with this. I have tried a lot now with vector-field-inputs in the modeler field calculator as well as in the modeler intersection tool. But in general, adressing a vector-input field as a varialbe seems to be tricky in the modeler. – L.Blanc Sep 2 '18 at 0:10
7

Inside a model fieldnames without any quotes separated by semicolon:

field1;field2;field3 
5
  • Is that documented somewhere? If so please provide a link. – csk Sep 1 '18 at 22:57
  • Hi ndawson, thanks for your help. I tried these possiblities: [Field1; Field2] as well as ["Field1"; "Field2"],[@Field1; @Field2] and also just @Field1; @Field2 but without any success. How does the syntax with the ";" work? – L.Blanc Sep 2 '18 at 0:04
  • Just field1;field2;field3 – ndawson Sep 2 '18 at 3:35
  • Thanks a lot! Now it worked. I always had a space character between the arguments: field1; field2 which did not work. Now without the space characters between the arguments, it works perfect with the fielsds-to-keep input in the intersection-algorithm. The drop-fields-algorithm in the modeler now also works great. Thanks for your help! – L.Blanc Sep 2 '18 at 11:49
  • I must admit, to me the information in the tool help and the input prompt in the intersection model were quite confusing. I searched for it a long time in the net and all the qgis helps and posts and never found anything about the style of the input syntax. Since the tool shows the information [not set] I always thought it has to be some kind of list, and a list has to be in [ ] brackets. – L.Blanc Sep 2 '18 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.