1

I would like to produce an atlas of 5 blocks for 16 variables. So for each atlas I display a layer who represent a variable. For each map in atlas I'm able de set a title with display block name with something like that :

'NDVI ' + "block_name_field"

But I have 16 variables and I don't want to handwrite it. Is code like that possible ?

Active_layer_name + "block_name_field"
2
  • 1
    Is there a function like @layer_name available? So maybe @layer_name + " block_name_field". Haven't really used Atlas myself so this is just a guess.
    – Joseph
    Sep 15, 2017 at 11:55
  • I tried it in expression editor. Preview shows atlas layer name and not variable layer. And in my title it finally displays nothing...
    – Tim C.
    Sep 15, 2017 at 12:02

1 Answer 1

1

In the plug-in Expressions Plus FR (derived from the original from N. Woodrow) you have a function called NamePathActiveLayer that almost does the job (you have at least file name of active layer ...)

or (better, i suppose) :

write your own expression, go in the expression dialog box, activate the function editor tab and try the following code :

    from qgis.core import *
    from qgis.gui import *
    from qgis.utils import iface

    @qgsfunction(args='auto', group='create_your_own_group')
    def ActiveLayerName(feature, parent):
      layer = iface.activeLayer()
      if layer != None :
      return layer.name()

You will have to save the code and the new function should be available (at qgis restart i think ...)

2
  • I can't find Expressions Plus FR. I have just N. Woodrow version. Have you more deposits than official deposit ?
    – Tim C.
    Sep 15, 2017 at 13:11
  • u're right ... not sure the deposit is visible ...
    – Snaileater
    Sep 15, 2017 at 14:29

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.