Skip to main content
added 2 characters in body
Source Link

Answer for anybody that would have the same question :

I found 2 ways to add a virtual field to an output (vector) layer from a model :

  1. Create a new process that edits the output layer of the model using the vector_layer.addExpressionField() method ; this process should normally be run before the model terminates and releases its outputs so the virtual field should be present in the output file. Pros : you get a lot of control over the buildingexpression of the field and you can use inputs from the model (to name the field for example).
  2. Add the virtual laye through a .qml style file using the Edit Rendering Style For Outputs menu ; the virtual field names and expression can be part of a .qml file, simply make sure the Fields section is checked when saving the style of an existing layer. Pros : no need to create a new process and you can modify all other sections of the style at the same time

If you do both things then the style applied by the .qml file will prevail, removing the virtual field that could have been added using the process so that the output layer perfectly satisfies the contents of the .QMLqml file.

Big thanks to Erik :)

Answer for anybody that would have the same question :

I found 2 ways to add a virtual field to an output (vector) layer from a model :

  1. Create a new process that edits the output layer of the model using the vector_layer.addExpressionField() method ; this process should normally be run before the model terminates and releases its outputs so the virtual field should be present in the output file. Pros : you get a lot of control over the building of the field and you can use inputs from the model (to name the field for example).
  2. Add the virtual laye through a .qml style file using the Edit Rendering Style For Outputs menu ; the virtual field names and expression can be part of a .qml file, simply make sure the Fields section is checked when saving the style of an existing layer. Pros : no need to create a new process and you can modify all other sections of the style at the same time

If you do both things then the style applied by the .qml file will prevail, removing the virtual field that could have been added using the process so that the output layer perfectly satisfies the contents of the .QML file.

Big thanks to Erik :)

Answer for anybody that would have the same question :

I found 2 ways to add a virtual field to an output (vector) layer from a model :

  1. Create a new process that edits the output layer of the model using the vector_layer.addExpressionField() method ; this process should normally be run before the model terminates and releases its outputs so the virtual field should be present in the output file. Pros : you get a lot of control over the expression of the field and you can use inputs from the model (to name the field for example).
  2. Add the virtual laye through a .qml style file using the Edit Rendering Style For Outputs menu ; the virtual field names and expression can be part of a .qml file, simply make sure the Fields section is checked when saving the style of an existing layer. Pros : no need to create a new process and you can modify all other sections of the style at the same time

If you do both things then the style applied by the .qml file will prevail, removing the virtual field that could have been added using the process so that the output layer perfectly satisfies the contents of the .qml file.

Big thanks to Erik :)

Source Link

Answer for anybody that would have the same question :

I found 2 ways to add a virtual field to an output (vector) layer from a model :

  1. Create a new process that edits the output layer of the model using the vector_layer.addExpressionField() method ; this process should normally be run before the model terminates and releases its outputs so the virtual field should be present in the output file. Pros : you get a lot of control over the building of the field and you can use inputs from the model (to name the field for example).
  2. Add the virtual laye through a .qml style file using the Edit Rendering Style For Outputs menu ; the virtual field names and expression can be part of a .qml file, simply make sure the Fields section is checked when saving the style of an existing layer. Pros : no need to create a new process and you can modify all other sections of the style at the same time

If you do both things then the style applied by the .qml file will prevail, removing the virtual field that could have been added using the process so that the output layer perfectly satisfies the contents of the .QML file.

Big thanks to Erik :)