Labeling using 'wordwrap' and 'wrap on character' with mutiple fields in QGIS?
I'm having a problem with multi-field labeling both using the 'wordwrap' function and the 'wrap on character' mode. In fact I would need to use the multiline mode only on the second of the two fields (setting the wrap_lenght to optimize the number of lines) but I have not succeeded in any way.
in the first image, on the left the correct formatting, on the right the formatting that I would like to correct but avoiding too many lines as on the right in the second image. The "number" is the first field while the "name" the second field.
I tried to solve the problem using the expression:
"FIELD_1" || '' || wordwrap ("FIELD_2", 12)
without changes in formatting,
and also using a rule based labeling with:
"FIELD_1" || ''
'' || wordwrap ("FIELD_2", 12)
but completely losing the formatting.
Is it possible to solve this problem?
qgis labeling
add a comment |
I'm having a problem with multi-field labeling both using the 'wordwrap' function and the 'wrap on character' mode. In fact I would need to use the multiline mode only on the second of the two fields (setting the wrap_lenght to optimize the number of lines) but I have not succeeded in any way.
in the first image, on the left the correct formatting, on the right the formatting that I would like to correct but avoiding too many lines as on the right in the second image. The "number" is the first field while the "name" the second field.
I tried to solve the problem using the expression:
"FIELD_1" || '' || wordwrap ("FIELD_2", 12)
without changes in formatting,
and also using a rule based labeling with:
"FIELD_1" || ''
'' || wordwrap ("FIELD_2", 12)
but completely losing the formatting.
Is it possible to solve this problem?
qgis labeling
add a comment |
I'm having a problem with multi-field labeling both using the 'wordwrap' function and the 'wrap on character' mode. In fact I would need to use the multiline mode only on the second of the two fields (setting the wrap_lenght to optimize the number of lines) but I have not succeeded in any way.
in the first image, on the left the correct formatting, on the right the formatting that I would like to correct but avoiding too many lines as on the right in the second image. The "number" is the first field while the "name" the second field.
I tried to solve the problem using the expression:
"FIELD_1" || '' || wordwrap ("FIELD_2", 12)
without changes in formatting,
and also using a rule based labeling with:
"FIELD_1" || ''
'' || wordwrap ("FIELD_2", 12)
but completely losing the formatting.
Is it possible to solve this problem?
qgis labeling
I'm having a problem with multi-field labeling both using the 'wordwrap' function and the 'wrap on character' mode. In fact I would need to use the multiline mode only on the second of the two fields (setting the wrap_lenght to optimize the number of lines) but I have not succeeded in any way.
in the first image, on the left the correct formatting, on the right the formatting that I would like to correct but avoiding too many lines as on the right in the second image. The "number" is the first field while the "name" the second field.
I tried to solve the problem using the expression:
"FIELD_1" || '' || wordwrap ("FIELD_2", 12)
without changes in formatting,
and also using a rule based labeling with:
"FIELD_1" || ''
'' || wordwrap ("FIELD_2", 12)
but completely losing the formatting.
Is it possible to solve this problem?
qgis labeling
qgis labeling
edited Dec 3 '18 at 5:15
PolyGeo♦
53.2k1779238
53.2k1779238
asked Dec 2 '18 at 23:41
Andrew-63
1528
1528
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can apply a condition to have more control on the labels if the length of text exceeds certain number of characters as follows:
case
when length("Field_2") < 6 then "Field_1" || 'n' || wordwrap("Field_2",6)
when length("Field_2") >= 6 then "Field_1" || 'n' || wordwrap("Field_2",12)
end
The numbers 6 and 10 are just an example, you need to adjust them based on your needs.
The output should look like this:
In the above examples the length of Smith County and Bob County are different but they stacked onto two lines based on the conditions above.
Thanks a lot! It seems to work perfectly
– Andrew-63
Dec 3 '18 at 12:38
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');
});
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%2f304680%2flabeling-using-wordwrap-and-wrap-on-character-with-mutiple-fields-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
You can apply a condition to have more control on the labels if the length of text exceeds certain number of characters as follows:
case
when length("Field_2") < 6 then "Field_1" || 'n' || wordwrap("Field_2",6)
when length("Field_2") >= 6 then "Field_1" || 'n' || wordwrap("Field_2",12)
end
The numbers 6 and 10 are just an example, you need to adjust them based on your needs.
The output should look like this:
In the above examples the length of Smith County and Bob County are different but they stacked onto two lines based on the conditions above.
Thanks a lot! It seems to work perfectly
– Andrew-63
Dec 3 '18 at 12:38
add a comment |
You can apply a condition to have more control on the labels if the length of text exceeds certain number of characters as follows:
case
when length("Field_2") < 6 then "Field_1" || 'n' || wordwrap("Field_2",6)
when length("Field_2") >= 6 then "Field_1" || 'n' || wordwrap("Field_2",12)
end
The numbers 6 and 10 are just an example, you need to adjust them based on your needs.
The output should look like this:
In the above examples the length of Smith County and Bob County are different but they stacked onto two lines based on the conditions above.
Thanks a lot! It seems to work perfectly
– Andrew-63
Dec 3 '18 at 12:38
add a comment |
You can apply a condition to have more control on the labels if the length of text exceeds certain number of characters as follows:
case
when length("Field_2") < 6 then "Field_1" || 'n' || wordwrap("Field_2",6)
when length("Field_2") >= 6 then "Field_1" || 'n' || wordwrap("Field_2",12)
end
The numbers 6 and 10 are just an example, you need to adjust them based on your needs.
The output should look like this:
In the above examples the length of Smith County and Bob County are different but they stacked onto two lines based on the conditions above.
You can apply a condition to have more control on the labels if the length of text exceeds certain number of characters as follows:
case
when length("Field_2") < 6 then "Field_1" || 'n' || wordwrap("Field_2",6)
when length("Field_2") >= 6 then "Field_1" || 'n' || wordwrap("Field_2",12)
end
The numbers 6 and 10 are just an example, you need to adjust them based on your needs.
The output should look like this:
In the above examples the length of Smith County and Bob County are different but they stacked onto two lines based on the conditions above.
answered Dec 3 '18 at 4:10
ahmadhanb
21.7k31951
21.7k31951
Thanks a lot! It seems to work perfectly
– Andrew-63
Dec 3 '18 at 12:38
add a comment |
Thanks a lot! It seems to work perfectly
– Andrew-63
Dec 3 '18 at 12:38
Thanks a lot! It seems to work perfectly
– Andrew-63
Dec 3 '18 at 12:38
Thanks a lot! It seems to work perfectly
– Andrew-63
Dec 3 '18 at 12:38
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f304680%2flabeling-using-wordwrap-and-wrap-on-character-with-mutiple-fields-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