2

I'm looking to get the file paths for the various layers into the QGIS print composer. This is so I can produce a block of copyright statements automatically as we use data from a wide range of sources that have different statements.

I've already tried using the layer variables, but it turns out that those don't get pulled through into Print Composer for some reason.

2
  • did you ever get one of these solutions to work for you? May 25, 2016 at 16:04
  • What I ended up doing was creating a custom function with no inputs and then doing the following for layer in iface.mapCanvas().layers(): with if statements to add a marker into a string. Then do a series of if statements to add the right copyrights based on the Markers in the string and then finally return the string. When I have some time, I'm going to try and clean it up using dictionaries but this works for the moment Jun 1, 2016 at 13:28

1 Answer 1

2

You should be able to use the 'layer_property' variable in a text label in a print composer:

  • add the text label
  • click the 'insert expression' button below the text box
  • in the 'search' box, type 'layer' and you can see a variable called 'layer_property'
  • you can use the layer name or layer ID (found in the layer properties)
  • add an expression like

    [%layer_property( 'council_districts20160406090721238', 'source')%]

Which will display the text label with the layers source (And I've manually added the layer name, but you can use the same expression to add it dynamically):

enter image description here

And this will work for PostGIS data, etc. as well...

Your Answer

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

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