How to create a label containing values from different layers in QGISHow to share styles between layers in...

What can I do to encourage my players to use their consumables?

Does it take energy to move something in a circle?

Cat is tipping over bed-side lamps during the night

A fantasy book with seven white haired women on the cover

What is a good reason for every spaceship to carry a weapon on board?

Can we "borrow" our answers to populate our own websites?

Renting a 2CV in France

Not a Long-Winded Riddle

Count repetitions of an array

What senses are available to a corpse subjected to a Speak with Dead spell?

If angels and devils are the same species, why would their mortal offspring appear physically different?

Why avoid shared user accounts?

Single-row INSERT...SELECT much slower than separate SELECT

Sitecore 9.1 Installation - Skip to particular step

What to do with threats of blacklisting?

Switch case implementation in Java for an integer pair combination

What's the oldest plausible frozen specimen for a Jurassic Park style story-line?

hrule into tikz circle node

Possible issue with my W4 and tax return

Illustrator to chemdraw

Prevent Nautilus / Nemo from creating .Trash-1000 folder in mounted devices

Why did Mr. Elliot have to decide whose boots were thickest in "Persuasion"?

Will rerolling initiative each round stop meta-gaming about initiative?

Why didn't the 2019 Oscars have a host?



How to create a label containing values from different layers in QGIS


How to share styles between layers in QGISHow to show labels for all polygons in a layer, even with 'NULL' values?How to display multiple attributes in a QGIS Composer legend?Can labels for overlapping points be combined/merged into one label?Single label for multiple features with different values in ArcGIS Desktop?Summing pixel values from several raster layers with partial overlap in QGIS?Summing values from different intersecting/overlapping points in QGISlabeling feature based on defined Value Map in QGIS?Suppress same label from different features QGisHow do I split subjacent lines and merge attributes in order to label them in QGIS













5















I have several layers which are stagged on each other. I need to create a label (or text-window / description, doesn't matter) which should contain values from different layers. Creating a regular label I can only choose attributes from this layer. Because the features have different nodes, it is not possible to just merge the layers.










share|improve this question









New contributor




KReisser is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Yes,but I can only select fields and values from the layer you are working on. I need to create a label / textwindow containing values from multiple layers.

    – KReisser
    6 hours ago











  • I think it is not possible, because QGIS can not know where the "imported" feature is, therefore not choose the right value from the table. That's why I asked another question: how to split lines and merge the attributes

    – KReisser
    6 hours ago
















5















I have several layers which are stagged on each other. I need to create a label (or text-window / description, doesn't matter) which should contain values from different layers. Creating a regular label I can only choose attributes from this layer. Because the features have different nodes, it is not possible to just merge the layers.










share|improve this question









New contributor




KReisser is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Yes,but I can only select fields and values from the layer you are working on. I need to create a label / textwindow containing values from multiple layers.

    – KReisser
    6 hours ago











  • I think it is not possible, because QGIS can not know where the "imported" feature is, therefore not choose the right value from the table. That's why I asked another question: how to split lines and merge the attributes

    – KReisser
    6 hours ago














5












5








5


3






I have several layers which are stagged on each other. I need to create a label (or text-window / description, doesn't matter) which should contain values from different layers. Creating a regular label I can only choose attributes from this layer. Because the features have different nodes, it is not possible to just merge the layers.










share|improve this question









New contributor




KReisser is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I have several layers which are stagged on each other. I need to create a label (or text-window / description, doesn't matter) which should contain values from different layers. Creating a regular label I can only choose attributes from this layer. Because the features have different nodes, it is not possible to just merge the layers.







qgis labeling






share|improve this question









New contributor




KReisser is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




KReisser is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 6 hours ago







KReisser













New contributor




KReisser is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 7 hours ago









KReisserKReisser

314




314




New contributor




KReisser is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





KReisser is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






KReisser is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • Yes,but I can only select fields and values from the layer you are working on. I need to create a label / textwindow containing values from multiple layers.

    – KReisser
    6 hours ago











  • I think it is not possible, because QGIS can not know where the "imported" feature is, therefore not choose the right value from the table. That's why I asked another question: how to split lines and merge the attributes

    – KReisser
    6 hours ago



















  • Yes,but I can only select fields and values from the layer you are working on. I need to create a label / textwindow containing values from multiple layers.

    – KReisser
    6 hours ago











  • I think it is not possible, because QGIS can not know where the "imported" feature is, therefore not choose the right value from the table. That's why I asked another question: how to split lines and merge the attributes

    – KReisser
    6 hours ago

















Yes,but I can only select fields and values from the layer you are working on. I need to create a label / textwindow containing values from multiple layers.

– KReisser
6 hours ago





Yes,but I can only select fields and values from the layer you are working on. I need to create a label / textwindow containing values from multiple layers.

– KReisser
6 hours ago













I think it is not possible, because QGIS can not know where the "imported" feature is, therefore not choose the right value from the table. That's why I asked another question: how to split lines and merge the attributes

– KReisser
6 hours ago





I think it is not possible, because QGIS can not know where the "imported" feature is, therefore not choose the right value from the table. That's why I asked another question: how to split lines and merge the attributes

– KReisser
6 hours ago










2 Answers
2






active

oldest

votes


















5














You can create a virtual layer that will compute the intersection between the layers and retrieve the desired values to be labeled. Then you would put a label on this virtual layer.



Here is an example between two line layers, but this approach can be generalized to other types.



Go to the menu Layer / Add layer / Add - Edit virtual layer and put the following definition:



SELECT a.myField nameA, b.myField nameB, st_intersection(a.geometry, b.geometry)
FROM myLayer1 a, myLayer2 b
WHERE st_intersects(a.geometry, b.geometry)


This will create a new layer. Label it using the formula nameA || nameB or any other one that would concatenate the information to be shown.



enter image description here






share|improve this answer


























  • That is magnificent!

    – Taras
    6 hours ago











  • @Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised

    – JGH
    6 hours ago











  • Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!

    – Taras
    6 hours ago











  • Wow that looks promising. Thank you very much! I tried it but it says "Referenced table a in query not found" . what are the variables to be changed? nameA/nameB are my layer-names, what else?

    – KReisser
    5 hours ago













  • @KReisser no, you need to change FROM a,b to your layer names (FROM myLayer1, myLayer2) . SELECT a.name -> change name to your field name (SELECT a.myField nameA ...) (I have updated the sample code)

    – JGH
    5 hours ago





















2














Have a look at the refFunctions Plugin. It allows you to create a reference to another layer and you can specify the field you want to reference:



Setup:




  • Point layer named points with id and field1 fields

  • Polygon layer named poly with id field


to Create the label for the poly layer I used this:



concat("id", ' with other ID: ', geomcontains('points', 'id') ,' and name :' ,  geomcontains('points', 'field1'))


Where:




  • "id" is the ID field of poly

  • geomcontains is the function from refFunctions

  • 'points' references my points layer and

  • 'id' is the ID field of points


Be aware this creates problems when you have many features inside one feature of the other layer (see gif for reference)
enter image description here






share|improve this answer
























  • Thank you, that seems helpful. But I need the label to be placed somewhere else, not on/near the feature, because it contains a lot of information. Usually I create a point-layer and link it to the layer with the values, where I create a point, the labels are displayed and are movable. But in this case I have two (or more) layers containing the requested values. Would that be possible with refFunctions?

    – KReisser
    4 hours ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






KReisser is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f313464%2fhow-to-create-a-label-containing-values-from-different-layers-in-qgis%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














You can create a virtual layer that will compute the intersection between the layers and retrieve the desired values to be labeled. Then you would put a label on this virtual layer.



Here is an example between two line layers, but this approach can be generalized to other types.



Go to the menu Layer / Add layer / Add - Edit virtual layer and put the following definition:



SELECT a.myField nameA, b.myField nameB, st_intersection(a.geometry, b.geometry)
FROM myLayer1 a, myLayer2 b
WHERE st_intersects(a.geometry, b.geometry)


This will create a new layer. Label it using the formula nameA || nameB or any other one that would concatenate the information to be shown.



enter image description here






share|improve this answer


























  • That is magnificent!

    – Taras
    6 hours ago











  • @Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised

    – JGH
    6 hours ago











  • Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!

    – Taras
    6 hours ago











  • Wow that looks promising. Thank you very much! I tried it but it says "Referenced table a in query not found" . what are the variables to be changed? nameA/nameB are my layer-names, what else?

    – KReisser
    5 hours ago













  • @KReisser no, you need to change FROM a,b to your layer names (FROM myLayer1, myLayer2) . SELECT a.name -> change name to your field name (SELECT a.myField nameA ...) (I have updated the sample code)

    – JGH
    5 hours ago


















5














You can create a virtual layer that will compute the intersection between the layers and retrieve the desired values to be labeled. Then you would put a label on this virtual layer.



Here is an example between two line layers, but this approach can be generalized to other types.



Go to the menu Layer / Add layer / Add - Edit virtual layer and put the following definition:



SELECT a.myField nameA, b.myField nameB, st_intersection(a.geometry, b.geometry)
FROM myLayer1 a, myLayer2 b
WHERE st_intersects(a.geometry, b.geometry)


This will create a new layer. Label it using the formula nameA || nameB or any other one that would concatenate the information to be shown.



enter image description here






share|improve this answer


























  • That is magnificent!

    – Taras
    6 hours ago











  • @Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised

    – JGH
    6 hours ago











  • Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!

    – Taras
    6 hours ago











  • Wow that looks promising. Thank you very much! I tried it but it says "Referenced table a in query not found" . what are the variables to be changed? nameA/nameB are my layer-names, what else?

    – KReisser
    5 hours ago













  • @KReisser no, you need to change FROM a,b to your layer names (FROM myLayer1, myLayer2) . SELECT a.name -> change name to your field name (SELECT a.myField nameA ...) (I have updated the sample code)

    – JGH
    5 hours ago
















5












5








5







You can create a virtual layer that will compute the intersection between the layers and retrieve the desired values to be labeled. Then you would put a label on this virtual layer.



Here is an example between two line layers, but this approach can be generalized to other types.



Go to the menu Layer / Add layer / Add - Edit virtual layer and put the following definition:



SELECT a.myField nameA, b.myField nameB, st_intersection(a.geometry, b.geometry)
FROM myLayer1 a, myLayer2 b
WHERE st_intersects(a.geometry, b.geometry)


This will create a new layer. Label it using the formula nameA || nameB or any other one that would concatenate the information to be shown.



enter image description here






share|improve this answer















You can create a virtual layer that will compute the intersection between the layers and retrieve the desired values to be labeled. Then you would put a label on this virtual layer.



Here is an example between two line layers, but this approach can be generalized to other types.



Go to the menu Layer / Add layer / Add - Edit virtual layer and put the following definition:



SELECT a.myField nameA, b.myField nameB, st_intersection(a.geometry, b.geometry)
FROM myLayer1 a, myLayer2 b
WHERE st_intersects(a.geometry, b.geometry)


This will create a new layer. Label it using the formula nameA || nameB or any other one that would concatenate the information to be shown.



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 5 hours ago

























answered 6 hours ago









JGHJGH

12.7k21137




12.7k21137













  • That is magnificent!

    – Taras
    6 hours ago











  • @Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised

    – JGH
    6 hours ago











  • Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!

    – Taras
    6 hours ago











  • Wow that looks promising. Thank you very much! I tried it but it says "Referenced table a in query not found" . what are the variables to be changed? nameA/nameB are my layer-names, what else?

    – KReisser
    5 hours ago













  • @KReisser no, you need to change FROM a,b to your layer names (FROM myLayer1, myLayer2) . SELECT a.name -> change name to your field name (SELECT a.myField nameA ...) (I have updated the sample code)

    – JGH
    5 hours ago





















  • That is magnificent!

    – Taras
    6 hours ago











  • @Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised

    – JGH
    6 hours ago











  • Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!

    – Taras
    6 hours ago











  • Wow that looks promising. Thank you very much! I tried it but it says "Referenced table a in query not found" . what are the variables to be changed? nameA/nameB are my layer-names, what else?

    – KReisser
    5 hours ago













  • @KReisser no, you need to change FROM a,b to your layer names (FROM myLayer1, myLayer2) . SELECT a.name -> change name to your field name (SELECT a.myField nameA ...) (I have updated the sample code)

    – JGH
    5 hours ago



















That is magnificent!

– Taras
6 hours ago





That is magnificent!

– Taras
6 hours ago













@Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised

– JGH
6 hours ago





@Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised

– JGH
6 hours ago













Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!

– Taras
6 hours ago





Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!

– Taras
6 hours ago













Wow that looks promising. Thank you very much! I tried it but it says "Referenced table a in query not found" . what are the variables to be changed? nameA/nameB are my layer-names, what else?

– KReisser
5 hours ago







Wow that looks promising. Thank you very much! I tried it but it says "Referenced table a in query not found" . what are the variables to be changed? nameA/nameB are my layer-names, what else?

– KReisser
5 hours ago















@KReisser no, you need to change FROM a,b to your layer names (FROM myLayer1, myLayer2) . SELECT a.name -> change name to your field name (SELECT a.myField nameA ...) (I have updated the sample code)

– JGH
5 hours ago







@KReisser no, you need to change FROM a,b to your layer names (FROM myLayer1, myLayer2) . SELECT a.name -> change name to your field name (SELECT a.myField nameA ...) (I have updated the sample code)

– JGH
5 hours ago















2














Have a look at the refFunctions Plugin. It allows you to create a reference to another layer and you can specify the field you want to reference:



Setup:




  • Point layer named points with id and field1 fields

  • Polygon layer named poly with id field


to Create the label for the poly layer I used this:



concat("id", ' with other ID: ', geomcontains('points', 'id') ,' and name :' ,  geomcontains('points', 'field1'))


Where:




  • "id" is the ID field of poly

  • geomcontains is the function from refFunctions

  • 'points' references my points layer and

  • 'id' is the ID field of points


Be aware this creates problems when you have many features inside one feature of the other layer (see gif for reference)
enter image description here






share|improve this answer
























  • Thank you, that seems helpful. But I need the label to be placed somewhere else, not on/near the feature, because it contains a lot of information. Usually I create a point-layer and link it to the layer with the values, where I create a point, the labels are displayed and are movable. But in this case I have two (or more) layers containing the requested values. Would that be possible with refFunctions?

    – KReisser
    4 hours ago
















2














Have a look at the refFunctions Plugin. It allows you to create a reference to another layer and you can specify the field you want to reference:



Setup:




  • Point layer named points with id and field1 fields

  • Polygon layer named poly with id field


to Create the label for the poly layer I used this:



concat("id", ' with other ID: ', geomcontains('points', 'id') ,' and name :' ,  geomcontains('points', 'field1'))


Where:




  • "id" is the ID field of poly

  • geomcontains is the function from refFunctions

  • 'points' references my points layer and

  • 'id' is the ID field of points


Be aware this creates problems when you have many features inside one feature of the other layer (see gif for reference)
enter image description here






share|improve this answer
























  • Thank you, that seems helpful. But I need the label to be placed somewhere else, not on/near the feature, because it contains a lot of information. Usually I create a point-layer and link it to the layer with the values, where I create a point, the labels are displayed and are movable. But in this case I have two (or more) layers containing the requested values. Would that be possible with refFunctions?

    – KReisser
    4 hours ago














2












2








2







Have a look at the refFunctions Plugin. It allows you to create a reference to another layer and you can specify the field you want to reference:



Setup:




  • Point layer named points with id and field1 fields

  • Polygon layer named poly with id field


to Create the label for the poly layer I used this:



concat("id", ' with other ID: ', geomcontains('points', 'id') ,' and name :' ,  geomcontains('points', 'field1'))


Where:




  • "id" is the ID field of poly

  • geomcontains is the function from refFunctions

  • 'points' references my points layer and

  • 'id' is the ID field of points


Be aware this creates problems when you have many features inside one feature of the other layer (see gif for reference)
enter image description here






share|improve this answer













Have a look at the refFunctions Plugin. It allows you to create a reference to another layer and you can specify the field you want to reference:



Setup:




  • Point layer named points with id and field1 fields

  • Polygon layer named poly with id field


to Create the label for the poly layer I used this:



concat("id", ' with other ID: ', geomcontains('points', 'id') ,' and name :' ,  geomcontains('points', 'field1'))


Where:




  • "id" is the ID field of poly

  • geomcontains is the function from refFunctions

  • 'points' references my points layer and

  • 'id' is the ID field of points


Be aware this creates problems when you have many features inside one feature of the other layer (see gif for reference)
enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered 5 hours ago









LaughULaughU

3,19441232




3,19441232













  • Thank you, that seems helpful. But I need the label to be placed somewhere else, not on/near the feature, because it contains a lot of information. Usually I create a point-layer and link it to the layer with the values, where I create a point, the labels are displayed and are movable. But in this case I have two (or more) layers containing the requested values. Would that be possible with refFunctions?

    – KReisser
    4 hours ago



















  • Thank you, that seems helpful. But I need the label to be placed somewhere else, not on/near the feature, because it contains a lot of information. Usually I create a point-layer and link it to the layer with the values, where I create a point, the labels are displayed and are movable. But in this case I have two (or more) layers containing the requested values. Would that be possible with refFunctions?

    – KReisser
    4 hours ago

















Thank you, that seems helpful. But I need the label to be placed somewhere else, not on/near the feature, because it contains a lot of information. Usually I create a point-layer and link it to the layer with the values, where I create a point, the labels are displayed and are movable. But in this case I have two (or more) layers containing the requested values. Would that be possible with refFunctions?

– KReisser
4 hours ago





Thank you, that seems helpful. But I need the label to be placed somewhere else, not on/near the feature, because it contains a lot of information. Usually I create a point-layer and link it to the layer with the values, where I create a point, the labels are displayed and are movable. But in this case I have two (or more) layers containing the requested values. Would that be possible with refFunctions?

– KReisser
4 hours ago










KReisser is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















KReisser is a new contributor. Be nice, and check out our Code of Conduct.













KReisser is a new contributor. Be nice, and check out our Code of Conduct.












KReisser is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f313464%2fhow-to-create-a-label-containing-values-from-different-layers-in-qgis%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

Should I use Docker or LXD?How to cache (more) data on SSD/RAM to avoid spin up?Unable to get Windows File...