5

I am building a modeler in QGIS 3.2.1, I want to use Refactor fields tool to change the name of a fixed field (fid to org_fid),This tool accepts a Fields mapping. I also noticed that there is a Fields Mapper type parameter in the QGIS Parameters. If I add a Fields Mapper type parameter to the Modeler, I can specify this parameter in the Fields mapping of the tool. But I don't know how to specify fid to org_fid.

I wonder if anyone can provide an example of using Fields Mapper in the modeler.

  • I did something similar in 2.18, adding a field consisting of two columns and then deleting these columns, all based on the vector table tools. – Erik Aug 9 '18 at 13:54
3
+50

It's quite simple. In the modeler there must be a vector input, a Fields Mapper and a refactor field at least. The refactor field will receive both files.

enter image description here

Set the Fields Mapper on Fields mapping box.

enter image description here

When you run, you can set the output file columns as you like, similar to MrXsquared's response, but the fields are not fixed, they can be redefined on each run.

enter image description here

Note that it is possible to map one layer and refactor on another. As long as it has the information it needs to obey the rules you put in.

| improve this answer | |
  • 1
    This is good, I'll award it the bounty once the time limit passes. I'm still wondering though, is this the only algorithm that can use the Field Mapper? Specifically I'm thinking about this question, where they want to use the Field Calculator on all the fields in a layer with an unknown number of fields. Can the Field Mapper be used to set up the fields that go into the Field Calculator? gis.stackexchange.com/q/338972/81764 – csk Oct 18 '19 at 14:06
  • 1
    It's not possible. The field calculator receives only one field, in which case it is possible to perform most of the functions through the refactor itself or the aggregate functions through the "Aggregates", which also receives the fields mapper. – Herbert Santos Oct 18 '19 at 14:35
  • Why sometimes is it not possible to set the Fields Mapper on Fields mapping box? I'm trying to replicate your example and it's not possible. – Geografisica Jun 17 at 14:01
  • @Geografisica are you using a different version of QGIS? I did it on 3.4.7 – Herbert Santos Jul 1 at 17:54
  • 1
    @Geografisica it seems that there is a bug with version 3.10, I was also unable to create the model. The fieldsmapper is not displayed in any situation. I believe that you will have to use another version. Maybe in the current 3.14 it is already corrected. – Herbert Santos Jul 10 at 15:38

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.