If I define a Vector Layer as an input parameter to a QGIS model, then the parameter name is exposed as a variable in a Field Calculator within the model, however I am unable to use this variable as I am not sure what data type it is. For example with a Vector Layer parameter of InData, I have tried evaluating the following expressions into a text field in a temporary layer:

@InData => ''

layer_properties(@InData, 'name') => NULL

layer_properties(@InData, 'id') => NULL

parameter( 'InData') => NULL

This is the model:


Variables exposed in Field Calculator (the expression doesn't seem to be case sensitive):


My question is - how do you use the @indata variable? For example, can I use it to extract the CRS of the input layer?

A workaround is to use one of the @layer / @layer_id variables in a field calculator as the first tool connected to the input in the model, but then the result will need to be stored as an attribute if it is needed later in the model (see How to access input layer properties from QGIS' Modeler?).


1 Answer 1


You can use layer_property function with @layer keyword. @layer returns input layer itself.

Normally, the first parameter of layer_property is a string representing layer name or ID. But in Modeler case, since you cannot know the name of layer passed as input, it's useless. Therefore, the other choice is to use @layer keyword instead of layer name.

layer_property(@layer, 'id') 
layer_property(@layer, 'crs')
  • 1
    Hi Kadir, this is what I was getting at in my last paragraph, however this approach is limited (or was when I wrote the question) to the first tool of the model as after that the layer variable is updated and no longer refers to the input dataset. Feb 15, 2021 at 16:36

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.