2

I'm trying a very simple task. I want to write the layer name in a new attribute column. I managed to do this using Field Calculator. But I need to do the same for a lot of files in batch mode, only available in Advanced Python Field Calculator. In Advanced Python... algorithm I inserted in the Formula field the same expression I used in Field Calculator: value = @layer_name. Unfortunately, python (from Advanced Python... algorithm does not recognize the variable @layer_name. Any ideas?

asked Mar 25, 2019 at 20:10
6
  • Why not to use **"Field Calculator" ** in processing also? Is also available. Second though, you can use **"Refactore Fields" ** algorithm to use some formulas. Commented Mar 25, 2019 at 22:18
  • Is this inside a model? Commented Mar 26, 2019 at 4:09
  • @GSienko I edited the original question. Because I want to do this in batch mode only available in"Advanced Python Field Calculator". I don't know what is and what you mean by "Refactore Fields". Commented Mar 26, 2019 at 22:15
  • @ndawson, no this is not inside any model. The algorithm is available in 'Processing Toolbox'. Commented Mar 26, 2019 at 22:15
  • In that case, why not hard code the layer name in your expression? Commented Mar 27, 2019 at 0:03

1 Answer 1

1

Use Field Calculator (not Advanced Field Calculator) from 'Processing Toolbox' in batch mode and as the field value write: decode_uri(@layer, 'layerName'). Works, i've checked it.

answered Jul 8, 2020 at 19:28

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.