Labels with leaders in QGIS
I used the following link to create labels with leaders, but since I have a polyline layer I used a different expression for the Geometry Generator:
make_line(
centroid($geometry),
make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony")
)
It appears to work, but looks quite ugly, where some of the leaders go past the geometry centroid as follows:
And others fail to reach it:
Why does this occur and how can I fix it?
qgis labeling
add a comment |
I used the following link to create labels with leaders, but since I have a polyline layer I used a different expression for the Geometry Generator:
make_line(
centroid($geometry),
make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony")
)
It appears to work, but looks quite ugly, where some of the leaders go past the geometry centroid as follows:
And others fail to reach it:
Why does this occur and how can I fix it?
qgis labeling
add a comment |
I used the following link to create labels with leaders, but since I have a polyline layer I used a different expression for the Geometry Generator:
make_line(
centroid($geometry),
make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony")
)
It appears to work, but looks quite ugly, where some of the leaders go past the geometry centroid as follows:
And others fail to reach it:
Why does this occur and how can I fix it?
qgis labeling
I used the following link to create labels with leaders, but since I have a polyline layer I used a different expression for the Geometry Generator:
make_line(
centroid($geometry),
make_point("auxiliary_storage_labeling_positionx", "auxiliary_storage_labeling_positiony")
)
It appears to work, but looks quite ugly, where some of the leaders go past the geometry centroid as follows:
And others fail to reach it:
Why does this occur and how can I fix it?
qgis labeling
qgis labeling
edited 12 hours ago
Taras
2,0702624
2,0702624
asked 12 hours ago
user32882user32882
1,10611127
1,10611127
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The centroid of the geometry is basically the centerpoint of the geometry's bounding box. Thus, it can be situated outside of the geometry, especially when it comes to lines. Only for straight lines the centerpoint will be "inside" the geometry.
You could use the middle of the line instead.
What is the expression to get the middle of the line?
– user32882
12 hours ago
1
@user32882, have you seen this thread Finding middle point (midpoint) of line in QGIS?? It might be something with$length/2
.
– Taras
12 hours ago
2
Nevermind, I found it. The expression should bemake_line( line_interpolate_point($geometry, $length/2), make_point( "auxiliary_storage_labeling_positionx" , "auxiliary_storage_labeling_positiony" ) )
– user32882
12 hours ago
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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%2f312607%2flabels-with-leaders-in-qgis%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The centroid of the geometry is basically the centerpoint of the geometry's bounding box. Thus, it can be situated outside of the geometry, especially when it comes to lines. Only for straight lines the centerpoint will be "inside" the geometry.
You could use the middle of the line instead.
What is the expression to get the middle of the line?
– user32882
12 hours ago
1
@user32882, have you seen this thread Finding middle point (midpoint) of line in QGIS?? It might be something with$length/2
.
– Taras
12 hours ago
2
Nevermind, I found it. The expression should bemake_line( line_interpolate_point($geometry, $length/2), make_point( "auxiliary_storage_labeling_positionx" , "auxiliary_storage_labeling_positiony" ) )
– user32882
12 hours ago
add a comment |
The centroid of the geometry is basically the centerpoint of the geometry's bounding box. Thus, it can be situated outside of the geometry, especially when it comes to lines. Only for straight lines the centerpoint will be "inside" the geometry.
You could use the middle of the line instead.
What is the expression to get the middle of the line?
– user32882
12 hours ago
1
@user32882, have you seen this thread Finding middle point (midpoint) of line in QGIS?? It might be something with$length/2
.
– Taras
12 hours ago
2
Nevermind, I found it. The expression should bemake_line( line_interpolate_point($geometry, $length/2), make_point( "auxiliary_storage_labeling_positionx" , "auxiliary_storage_labeling_positiony" ) )
– user32882
12 hours ago
add a comment |
The centroid of the geometry is basically the centerpoint of the geometry's bounding box. Thus, it can be situated outside of the geometry, especially when it comes to lines. Only for straight lines the centerpoint will be "inside" the geometry.
You could use the middle of the line instead.
The centroid of the geometry is basically the centerpoint of the geometry's bounding box. Thus, it can be situated outside of the geometry, especially when it comes to lines. Only for straight lines the centerpoint will be "inside" the geometry.
You could use the middle of the line instead.
answered 12 hours ago
ErikErik
3,223322
3,223322
What is the expression to get the middle of the line?
– user32882
12 hours ago
1
@user32882, have you seen this thread Finding middle point (midpoint) of line in QGIS?? It might be something with$length/2
.
– Taras
12 hours ago
2
Nevermind, I found it. The expression should bemake_line( line_interpolate_point($geometry, $length/2), make_point( "auxiliary_storage_labeling_positionx" , "auxiliary_storage_labeling_positiony" ) )
– user32882
12 hours ago
add a comment |
What is the expression to get the middle of the line?
– user32882
12 hours ago
1
@user32882, have you seen this thread Finding middle point (midpoint) of line in QGIS?? It might be something with$length/2
.
– Taras
12 hours ago
2
Nevermind, I found it. The expression should bemake_line( line_interpolate_point($geometry, $length/2), make_point( "auxiliary_storage_labeling_positionx" , "auxiliary_storage_labeling_positiony" ) )
– user32882
12 hours ago
What is the expression to get the middle of the line?
– user32882
12 hours ago
What is the expression to get the middle of the line?
– user32882
12 hours ago
1
1
@user32882, have you seen this thread Finding middle point (midpoint) of line in QGIS?? It might be something with
$length/2
.– Taras
12 hours ago
@user32882, have you seen this thread Finding middle point (midpoint) of line in QGIS?? It might be something with
$length/2
.– Taras
12 hours ago
2
2
Nevermind, I found it. The expression should be
make_line( line_interpolate_point($geometry, $length/2), make_point( "auxiliary_storage_labeling_positionx" , "auxiliary_storage_labeling_positiony" ) )
– user32882
12 hours ago
Nevermind, I found it. The expression should be
make_line( line_interpolate_point($geometry, $length/2), make_point( "auxiliary_storage_labeling_positionx" , "auxiliary_storage_labeling_positiony" ) )
– user32882
12 hours ago
add a comment |
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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%2f312607%2flabels-with-leaders-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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
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