eyecatch

Show Attribute Values on a Map with Labels

Published: Last updated:
This article uses QGIS 3.34. The current LTR is 3.44.

What you'll learn


  • How to show labels for vector data
  • How to customize label display

Recommended for


  • Anyone who wants to add labels to vector data in QGIS
  • Anyone who wants to show attribute values as text on a map
  • Anyone who wants to change the position of labels on a map
  • Anyone who wants to show or hide text on a map depending on the scale

Introduction

In QGIS, you use the labeling feature to show attribute values on the map.

Adding labels to a map makes information easier to convey visually and helps readers understand the data. This article explains how to show labels for vector data in QGIS.

Basics of showing labels on vector data

First, check the attribute data of the vector data you want to label.

This example uses administrative area data for Tokyo. The attribute table shows that the N03_001 column holds the prefecture name, the N03_003 column holds the county name, and the N03_004 column holds the municipality name.

The municipality name is stored in the N03_004 column (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))
The municipality name is stored in the N03_004 column (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))

Now label the administrative area polygons with the municipality names (N03_004).

Right-click the administrative area layer in the Layers panel and open the Layer Properties dialog. Select the Labels tab on the left. By default, the drop-down at the top is set to No Labels. Select Single Labels from the drop-down.

Select Single Labels from the drop-down at the top
Select Single Labels from the drop-down at the top

The label settings appear below. Click the ▼ button next to Value and select the column you want to show as the label.

Here, select the N03_004 column, which holds the municipality names. When you finish, click the OK button at the bottom.

Select the N03_004 column, which holds the municipality names
Select the N03_004 column, which holds the municipality names

The municipality names now appear on the administrative area polygons. Some municipalities show the same name more than once. This happens because they consist of multiple polygons, for example because of exclaves.

The municipality names appear on the administrative area polygons (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))
The municipality names appear on the administrative area polygons (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))

Customize the label style

Labels use a basic style by default, but QGIS lets you fine-tune how labels look.

Change the font and color

In the Text tab, you can change the font size, style, and color.

The Text tab lets you adjust the text color, font, and more
The Text tab lets you adjust the text color, font, and more

To make labels easier to see, you can also change the text color, emphasize the text in bold, and add an underline.

Red text emphasized with bold and an underline (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))
Red text emphasized with bold and an underline (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))

Adjust label placement

In the Placement tab, you can adjust where labels appear.

The Placement tab lets you adjust where labels appear
The Placement tab lets you adjust where labels appear

For polygon data, the placement mode is set to Around Centroid by default, so labels appear near the centroid of each polygon.

With Around Centroid, labels appear near the centroid of each feature (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))
With Around Centroid, labels appear near the centroid of each feature (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))

To change where labels appear more flexibly, change the placement mode.

To change where labels appear more flexibly, change the placement mode
To change where labels appear more flexibly, change the placement mode
Examples of each placement mode. Each mode has its own detailed settings
Examples of each placement mode. Each mode has its own detailed settings

Set label visibility by scale

If you zoom in and out on the map canvas with labels showing, the labels can dominate the map and make it hard to see, as in the figure below.

At a large scale, the labels make the map hard to see (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))
At a large scale, the labels make the map hard to see (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))

In QGIS, you can show or hide labels automatically depending on the scale of the map canvas. For example, labels appear when you zoom in to see a detailed map and disappear when you zoom out, which keeps the map visually clean.

You set label visibility by scale in the Rendering tab.

Select the Rendering tab and check Scale dependent visibility at the top. Then enter the range of scales at which labels should appear in the fields with the minus and plus magnifier icons. Here, labels should not appear at 1:100000 or smaller, so click the ▼ button of the field with the minus magnifier icon and select 1:100000. Click the OK button, then change the scale of the map canvas.

Check Scale dependent visibility and set the scales as needed (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))
Check Scale dependent visibility and set the scales as needed (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))

Labels no longer appear at scales of 1:100000 or smaller, and they appear at scales larger than 1:100000.

Labels now appear at scales larger than 1:100000 (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))
Labels now appear at scales larger than 1:100000 (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))

Labels are a convenient way to show the attributes of features as text, but showing them indiscriminately can slow down the display and clutter the map, making it harder to understand. Set visibility by scale where needed to keep the map canvas easy to read.

Label buffer settings

When labels are displayed, the text can be hard to see against the features behind it. In that case, add a buffer (outline) around the label.

You set the label buffer in the Buffer tab.

Select the Buffer tab and check Draw text buffer. You can also set the buffer Size, Color, and more, but here, keep the default settings and click the OK button.

Check Draw text buffer to show the buffer (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))
Check Draw text buffer to show the buffer (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))

On the map canvas, the text now has a white buffer, so it is clearly visible.

The label text now has a buffer (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))
The label text now has a buffer (Created by processing “National Land Numerical Information (Administrative Area Data)” (Ministry of Land, Infrastructure, Transport and Tourism))

Conclusion

This article introduced the basic labeling features: showing labels, placement modes, visibility by scale, and buffers.

Labels have many other features, such as showing callouts (leader lines) and displaying multiple attributes on separate lines. Other articles will cover more advanced uses.

About the author
QGIS LAB Editorial Team
QGIS LAB Editorial Team

QGIS LAB is a comprehensive information hub for QGIS, the open-source GIS software. Under the concept of “Geospatial for Greater Good,” we share the knowledge and skills to open up the world through location data.