I'm making a map of North Dakota and trying to label the counties, but one of the names (Golden Valley) is extremely long in a very tall county. I don't want to turn the label vertically, but would rather put 'Golden Valley' on two lines so it will fit.

Is it possible to edit only that label so that it is on two lines? And how?

  • Ok, I got that to work, but now I have a new problem. I had a rule on my labels that would label information from another column in my attribute table to be on a line directly under the county name. This rule on its own works, and the word wrap rule is working on its own, but they aren't working together. It's probably an obvious answer, but is there a specific operator I would need to place between both of these rules for them to both apply? – N. Betland Nov 15 at 0:43
up vote 2 down vote accepted

You can use wordwrap() function with condition in the expression to wrap only 'Golden Valley' when defining the field to use in Label with:

enter image description here

Here is the expression to use:

Case
When  "CountyNM" =  'Golden Valley' Then wordwrap("CountyNM",6)
else "CountyNM"
End 

Where "CountyNM" is the field name in this example. You need to change it based on the field name you are using.

Here is the result:

enter image description here

Set the labeling type to rule-based labeling,

enter image description here

Then create a rule which filters out Golden Valley, label it with the expression 'Golden\nValley'. "\n" is a line break operator so it forces the next part of the string on to the next line.

Then create a second rule with the filter ELSE, this will include all the other labels.

enter image description here

Or there is the third option: In data table you can add any symbol between respective words (in my example it is a symbol ►_◄). And everywhere when there will be ►_◄ it will wrap. In this case you won't need to make any rule-based labels or to add new names in an expression.

But remember this symbol will stay there, and you must do the same action in labels (wrap on character) in every new project using this data.

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.