Docs
12 Labeling
Introduction
Labels in QGIS are an important feature for displaying textual information, such as place names, street names or other relevant attributes, directly on the map. By customizing labels, you can ensure that your map is not only informative but also aesthetically pleasing. QGIS offers a variety of options to control the placement, display and behavior of labels.
1. set basic labeling
A. Activate labels
- Open layer properties:
- Right-click on a vector layer and select Properties from the context menu.
- Labeling” tab:
- Go to the Label tab in the “Layer properties” dialog.
- Activate labels:
- In the “Label with” drop-down menu, select the attribute field that is to be used for the labels (e.g.
name
,ID
or another relevant field).
B. Customizing text styles
- Font and size:
- Under Text, you can set the font, size, color and style (e.g. bold, italic) of the caption.
- Color and transparency:
- Choose a suitable font color and adjust the transparency to improve readability.
- Background and frame:
- To further increase the legibility of the labels, you can add a background or frame. This is particularly useful if the labels are placed over complex map elements.
2. advanced labeling settings
A. Placement of the labeling
- Placement options:
- Under the Placement tab, you can specify where the labels should appear relative to the features. QGIS offers options for placement above, below, left, right or in the center of features.
- Anchor points:
- Select the anchor point that determines which part of the label is oriented to the defined position.
- Offset and alignment:
- Adjust the offset to move the label slightly and use the alignment options to align the text within the anchor point.
B. Collision detection and overlapping
- Avoid labeling:
- Activate the Avoid labels option to ensure that labels do not lie on top of each other. This helps to ensure a clear and uncluttered map display.
- Prioritize labeling:
- Set priorities for labels so that more important labels are always displayed, while less important ones can be hidden to avoid collisions.
- Feature-related placement:
- Under Feature-related placement, you can specify how the labeling should behave for complex or closely spaced features.
3. labeling based on expressions
A. Dynamic labels with expressions
- Printout-based labeling:
- Select the Label with expression option to generate labels based on a custom expression. This allows you to combine multiple attributes or perform calculations to create the text for the labels.
- Example expression:
- An example of an expression could be
concat("name", ' (', "type", ')')
to create labels such as “Berlin (city)”.
- Preview and validation:
- Use the preview option to see how the labels will look on the card and make sure the printout is correct.
4. labeling with data dependency
A. Data-dependent properties
- Property binding:
- Many labeling properties in QGIS can be bound to attributes. Click on the small data icon next to a property (e.g. font size) to make the property dependent on an attribute or expression.
- Size and style based on attributes:
- For example, you can vary the font size in proportion to the population size or the font color depending on a status field.
- Data-dependent visibility:
- Set conditions under which a label is only displayed if certain criteria are met (e.g. only cities with a certain number of inhabitants).
5. save and load labeling styles
A. Save labeling style
- Save labeling style:
- Once you have created a labeling style, you can save it by clicking on Save in the “Labeling” tab. The style is saved as a .qml file.
B. Load labeling style
- Load labeling style:
- To use a saved labeling style, click on Load and select the corresponding .qml file.
6. best practices
- Test labels: Make sure that the labels on your map remain legible at different scales and do not obscure any important map elements.
- Observe labeling rules: Apply rules for prioritizing and avoiding collisions to ensure a clear and clean map display.
- Keep style consistent: Use consistent fonts, sizes and colors throughout your project to ensure a unified look.
Labels are a powerful tool in QGIS to make maps informative and understandable. With multiple customization options, you can ensure that your labels are clear, concise and aesthetically pleasing.