I tried to use the refactor field processing after my model creates the two layers needed to calculate the expression:

line_locate_point(geometry:=geometry(get_feature('LH_fusion', 'id', '1')), point:=end_point($geometry))


However it seems QGIS can't use any temporary outputs from the model itself (see Refering to the input-layer of a QGIS model in field calculator expression)

What could be a good work around for such a case ?

I had thought about virtual fields which can handle real time updates but I don't really see how.

Or maybe a Python script which recalculate each lines according to the expression set by the refactor field algorithm like here: Update virtual field on demand (not permanently) (QGIS)

1 Answer 1


I did understand you would like to modify the source layer with the qgis modeler. It is not possible and all your output of your modeler will be a layer.

what is possible is to do dynamic join between your layer and the layer you just produce (the target layer) to get the data back to your source layer. If you have in the both layer a common field named fid then use the field calculator to evaluate this expression :

attributes(get_feature('NAME_OF_YOUR_TARGET_LAYER' ,'fid' , "fid")) [FIELD_NAME_IN_YOUR_TARGET_LAYER]

If I didn't answer your question don't please add more information to understand your willing.

  • I want to make the last calculation automatic, without the help of the field calculator. My model produce two outputs : one points layer and a line layer. I want to add to the points layers produced by the model/script a new field which show the relative distance between points along the line layer with the expression line_locate_point(geometry:=geometry(get_feature('LH_fusion', 'id', '1')), point:=end_point($geometry))
    – Caligraphy
    Jun 16, 2021 at 14:03
  • Do you need the intermediate step at the end or just the end layer ? If you need only end layer why don't you use expression field calculator within the model ? You can refer to it, the only difficulty you may have will be to construct an expression based on a process made in the model. Jun 16, 2021 at 21:16
  • I would like to keep intermediate steps as my points / lines layers ( 'LH_fusion', 'Shelters_intersection') and a third and final end layer which contains a new field expressing the above formula. I tried to swap 'Refactor fields' algorithm by the 'Field calculator' and applied the expression to an existing field. However it results into a 'NULL' filled field which is caused by the known problem mentionned by N.Dawson
    – Caligraphy
    Jun 17, 2021 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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