6

Is it possible to add a layer credit to the bottom right corner of the map and print composer in QGIS 3.4? This fuctionality existed in 2.8, as seen here.

I can't find this option in the layer properties anymore. I realize I can do something similar manually via the Copyright Decoration, but it was nice to just check/uncheck a box when needed. The Copyright Decoration is also always on top and visible.

Perhaps someone can suggest an expression to use in the Copyright Decoration that will pull the visible layer's metadata and use that as the text string? My QGIS expression skills aren't that strong yet.

2 Answers 2

8

Building on J. Monticolo's excellent answer, here's a method that gives attributions for all visible layers.

  • @map_layer_ids returns a list (or "array") of the visible map layers
  • array_get() returns a single item from a list
  • array_get( @map_layer_ids ,0) returns the first item from the list of visible map layers
  • concat() combines multiple text strings

For a map with eight layers in the layer panel, use this expression to combine the attributions of all the visible layers, separated with a space:

concat(
layer_property( array_get( @map_layer_ids ,0),'attribution') || ' ',
layer_property( array_get( @map_layer_ids ,1),'attribution') || ' ',
layer_property( array_get( @map_layer_ids ,2),'attribution') || ' ',
layer_property( array_get( @map_layer_ids ,3),'attribution') || ' ',
layer_property( array_get( @map_layer_ids ,4),'attribution') || ' ',
layer_property( array_get( @map_layer_ids ,5),'attribution') || ' ',
layer_property( array_get( @map_layer_ids ,6),'attribution') || ' ',
layer_property( array_get( @map_layer_ids ,7),'attribution'))

enter image description here

Notes:

Add or subtract lines so there's one for every layer in your project. When the expression is evaluated, it only applies to visible layers. By creating sure you have a line for every map layer, you cover every possible combination of enabled/disabled layers.

Note that the array is 0 indexed, so the first map layer has the index value 0, and the last map layer has the index value (total number of layers) - 1.

You can change the separator between attributions. For example, to use a semicolon, substitute ';' for ' '.

Layers without any attribution are omitted automatically. If you see extra spaces in the attribution as displayed on the map, check if any of the layers have a space in their attribution field.

4
  • Both great answers from J. Monticolo and csk! Thanks! J. Monticolo, kudos for simplcity and versatility. csk, I ended up modifying your answer based on the assumption that my maps will only ever need 1 attribution for a base map, and no other data citations. I would go back to your method for citing more than a single layer source. The expression is: layer_property(array_get(@map_layer_ids, array_length(@map_layer_ids )-1),'attribution') to select the bottom-most visible layer. For my purposes, this is a fair assumption, YMMV. Thanks again, super pleased with my first post to gis.stackexchange Feb 12, 2019 at 19:43
  • Please put this in a comment under @csk 's answer instead of another answer. This will keep the question cleaner (check the tour and try to not post thanks and greetings). Otherwise, welcome to GIS:SE!
    – Gabriel
    Feb 12, 2019 at 19:52
  • @ablairification Welcome to GIS SE! As a new user be sure to take the Tour. You tried to say thank you in the area reserved for direct answers to the original question, and such cases posts are normally deleted. In this instance yours was converted to a comment instead. The way to say thanks here is to upvote (or accept answers to your own questions).
    – PolyGeo
    Feb 12, 2019 at 22:54
  • 1
    An even better answer, for QGIS 3.6 and above is to use: array_to_string( array_filter( array_foreach( @map_layers, layer_property(@element,'attribution')), @element), ',') This will dynamically handle all map layers, regardless of how many are in the project.
    – ndawson
    Feb 12, 2019 at 22:56
6
  • In QGIS 3.x, go to the View menu > Decorations > Copyright Label.

  • Insert an expression ...

  • In the layers group, double-click on the raster layer you want to 'decorate', this will gives its ID

  • Copy and paste the layer ID in the following expression :

    layer_property('raster_layer_ID', 'attribution')

  • Click Ok twice.

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.