How to create a label containing values from different layers in QGISHow to share styles between layers in...
What is a good reason for every spaceship to carry gun on board?
Critique vs nitpicking
Single-row INSERT...SELECT much slower than separate SELECT
What to do with threats of blacklisting?
Can me and my friend spend the summer in Canada (6 weeks) at 16 years old without an adult?
What is the draw frequency for 3 consecutive games (same players; amateur level)?
Writing dialogues for characters whose first language is not English
Possible issue with my W4 and tax return
Does diversity provide anything that meritocracy does not?
How to not let the Identify spell spoil everything?
How can I handle players killing my NPC outside of combat?
How is this property called for mod?
How to fly a direct entry holding pattern when approaching from an awkward angle?
Why is Shelob considered evil?
Modern Algebraic Geometry and Analytic Number Theory
How do you get out of your own psychology to write characters?
Is it possible to detect 100% of SQLi with a simple regex?
Is there any danger of my neighbor having my wife's signature?
Where does documentation like business and software requirement spec docs fit in an agile project?
What can I do to encourage my players to use their consumables?
Plausible reason for gold-digging ant
How to write cases in LaTeX?
Converting very wide logos to square formats
How to completely remove a package in Ubuntu (like it never existed)
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
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
New contributor
add a comment |
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
New contributor
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
58 mins 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
52 mins ago
add a comment |
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
New contributor
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
qgis labeling
New contributor
New contributor
edited 1 hour ago
KReisser
New contributor
asked 1 hour ago
KReisserKReisser
263
263
New contributor
New contributor
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
58 mins 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
52 mins ago
add a comment |
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
58 mins 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
52 mins 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
58 mins 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
58 mins 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
52 mins 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
52 mins ago
add a comment |
2 Answers
2
active
oldest
votes
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.
That is magnificent!
– Taras
45 mins ago
@Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised
– JGH
43 mins ago
Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!
– Taras
36 mins 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
28 mins ago
@KReisser no, you need to changeFROM a,b
to your layer names (FROM myLayer1, myLayer2
) .SELECT a.name
-> changename
to your field name (SELECT a.myField nameA ...
) (I have updated the sample code)
– JGH
17 mins ago
|
show 1 more comment
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)
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
That is magnificent!
– Taras
45 mins ago
@Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised
– JGH
43 mins ago
Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!
– Taras
36 mins 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
28 mins ago
@KReisser no, you need to changeFROM a,b
to your layer names (FROM myLayer1, myLayer2
) .SELECT a.name
-> changename
to your field name (SELECT a.myField nameA ...
) (I have updated the sample code)
– JGH
17 mins ago
|
show 1 more comment
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.
That is magnificent!
– Taras
45 mins ago
@Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised
– JGH
43 mins ago
Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!
– Taras
36 mins 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
28 mins ago
@KReisser no, you need to changeFROM a,b
to your layer names (FROM myLayer1, myLayer2
) .SELECT a.name
-> changename
to your field name (SELECT a.myField nameA ...
) (I have updated the sample code)
– JGH
17 mins ago
|
show 1 more comment
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.
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.
edited 16 mins ago
answered 49 mins ago
JGHJGH
12.7k21137
12.7k21137
That is magnificent!
– Taras
45 mins ago
@Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised
– JGH
43 mins ago
Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!
– Taras
36 mins 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
28 mins ago
@KReisser no, you need to changeFROM a,b
to your layer names (FROM myLayer1, myLayer2
) .SELECT a.name
-> changename
to your field name (SELECT a.myField nameA ...
) (I have updated the sample code)
– JGH
17 mins ago
|
show 1 more comment
That is magnificent!
– Taras
45 mins ago
@Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised
– JGH
43 mins ago
Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!
– Taras
36 mins 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
28 mins ago
@KReisser no, you need to changeFROM a,b
to your layer names (FROM myLayer1, myLayer2
) .SELECT a.name
-> changename
to your field name (SELECT a.myField nameA ...
) (I have updated the sample code)
– JGH
17 mins ago
That is magnificent!
– Taras
45 mins ago
That is magnificent!
– Taras
45 mins ago
@Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised
– JGH
43 mins ago
@Taras :-) Virtual layers are truly powerful! I believe they should be much more advertised
– JGH
43 mins ago
Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!
– Taras
36 mins ago
Exactly! Once @J.R gave me a hint and afterwards I started to use them by myself. It helps a lot!
– Taras
36 mins 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
28 mins 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
28 mins 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
17 mins 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
17 mins ago
|
show 1 more comment
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)
add a comment |
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)
add a comment |
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)
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)
answered 11 mins ago
LaughULaughU
3,17441232
3,17441232
add a comment |
add a comment |
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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
58 mins 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
52 mins ago