12.3. ラベルの設定

ラベルは、ベクタの地物に表示できるテキスト情報です。 それらは、シンボルのみでは表すことができない詳細を追加します。

The Style Manager dialog allows you to create a set of labels or text formats (ie the appearance of the text, including font, size, colors, shadow, background...). Each of these items could later be applied to layers in the labeling Labels tab of the vector Layer Properties dialog or Layer Styling panel or using the labeling Layer Labeling Options button of the Labels toolbar. You can also directly configure them in the abovementioned dialogs.

The Label Settings dialog allows you to configure smart labeling for vector layers. Setting a label includes configuring the text format, and how the label relates with the features or other labels (through placement, rendering and callout).

12.3.1. ラベルテキストの整形


  1. Open the styleManager Style Manager dialog

  2. Activate the Text format tab


    図 12.13 スタイルマネージャダイアログのテキスト形式

  3. Press the signPlus Add item button. The Text Settings dialog opens with the following properties. As usual, these properties are data-definable. テキスト


図 12.14 テキスト設定 - テキストタブ

In the text Text tab, you can set:

  • フォント, マシンで使用可能なフォントに設定できます

  • スタイル:フォントの一般的なスタイルおよび、テキストの下線または取り消し線の設定ができます

  • the Size in any supported unit

  • 不透明度

下部にあるテキスト形式リストウィジェットには、 :ref:`スタイルマネージャデータベース<vector_style_manager>`内に保存されているフィルター可能なテキスト形式のリストが表示されます。これにより、ローカルのスタイルデータベースに保存されているスタイルと一致するようにテキスト形式を簡単に設定したり、現在の設定に基づいてスタイルデータベースに新しいテキスト形式を追加したりできます。 :guilabel:`設定を保存`ボタンを押して、現在のテキスト形式を :guilabel:`スタイルマネージャ`に保存し、名前とタグを指定します。

同様に、ラベルを構成時にラベル設定リストウィジェットが表示され、styleManager :sup:`スタイルマネージャ`ウィジェットから選択したり、新しいスタイルをウィジェットに追加したりできます。 整形


図 12.15 テキスト設定 - 整形タブ

labelformatting 整形 タブでは、次の設定を行うことができます:

  • Use the Type case option to change the capitalization style of the text. You have the possibility to render the text as All uppercase, All lowercase or Capitalize first letter. Note that the last option modifies only the first letter of each word and leaves the other letters in the text untouched.

  • :guilabel:`間隔`では、単語間および個々の文字間のスペースを変更します。

  • テキストフォントの|checkbox| カーニングを有効にする

  • テキストの向き では 水平 または :guilabel:`垂直`を設定できます。 ラベル設定時は :guilabel:`回転`を設定することもできます。

  • Use the Blend mode option to determine how your labels will mix with the map features below them (more details at 描画モード).

  • unchecked :guilabel:`置換リストを適用`オプションを使用すると、ラベルのテキストに置き換える置換リストを指定できます(例:通りの種類の省略)。置換テキストはマップにラベルを表示している際に使用されます。ユーザーは置換リストのエクスポートおよびインポートにより、簡単に再利用と共有ができます。

  • Configure Multiple lines:

    • :guilabel:`改行する文字`オプションを使用して、テキストを強制的に改行する文字を設定します。

    • Set an ideal line size for auto-wrapping using the Wrap lines to option. The size can represent either the Maximum line length or the Minimum line length.

    • Decide the Line Height

    • 整列`の体裁:利用可能な一般的な値は:guilabel:`左 、:guilabel:`中央`です。


  • ラインのラベルの場合は、 行方向シンボル`を含めて行方向を決定し、:guilabel:`左寄せ または :guilabel:`右寄せ`を示すシンボルを使用することができます。特に*湾曲* または *平行*配置オプションと一緒に使用するとうまく機能します。

  • Use the unchecked Formatted numbers option to format numeric texts. You can set the number of Decimal places. By default, 3 decimal places will be used. Use the checkbox Show plus sign if you want to show the plus sign for positive numbers. バッファ


図 12.16 テキスト設定 - バッファタブ

To create a buffer around the label, activate the checkbox Draw text buffer checkbox in the labelbuffer Buffer tab. Then you can:

  • バッファの:guilabel:`サイズ`はいずれかの :ref:`supported unit <unit_selector>`で設定します。

  • バッファの:guilabel:`色`を選択します。

  • checkbox カラーバッファの塗りつぶし: バッファーはラベルのアウトラインから拡張されるため、オプションがアクティブになっている場合、ラベルの内部が塗りつぶされます。これは、部分的に透明なラベルを使用する場合、またはラベルのテキストの後ろを見ることができるような通常以外の描画モードで関連する場合があります。オプションをオフにすると(完全に透明なラベルを使用している間)、アウトライン化されたテキストラベルを作成できます。

  • バッファの:guilabel:`不透明度`を定義する

  • 継ぎ目スタイル丸み(Round)留め継ぎ(Miter) または :guilabel:`角型(Bevel)`から適用できます

  • Use the Blend mode option to determine how your label's buffer will mix with the map components below them (more details at 描画モード).

  • unchecked描画エフェクト`にチェックをして、テキストの読みやすさを向上させるための高度な|paintEffects|:ref:`paint effects <draw_effects> を追加します。例:アウターグローとぼかしを使って 背景


  • 四角形正方形 または:guilabel:`楕円`などの規則的な形状

  • URLまたはプロジェクトまたはスタイルデータベースに埋め込まれているファイルからの:guilabel:SVG`シンボル(:ref:`more details <svg_paths>)

  • または、symbol library <vector_marker_symbols>`から作成または選択できる:guilabel:`マーカーシンボル


図 12.17 テキスト設定 - 背景タブ

Depending on the selected shape, you need to configure some of the following properties:

  • The Size type of the frame, which can be:

    • Fixed: using the same size for all the labels, regardless the size of the text

    • or a Buffer over the text's bounding box

  • The Size of the frame in X and Y directions, using any supported units

  • A Rotation of the background, between Sync with label, Offset of label and Fixed. The last two require an angle in degrees.

  • An Offset X,Y to shift the background item in the X and/or Y directions

  • A Radius X,Y to round the corners of the background shape (applies to rectangle and square shapes only)

  • An Opacity of the background

  • A Blend mode to mix the background with the other items in the rendering (see 描画モード).

  • The Fill color, Stroke color and Stroke width for shape types other than the marker symbol. Use the Load symbol parameters to revert changes on an SVG symbol to its default settings.

  • A Pen join style: it can be Round, Miter or Bevel (applies to rectangle and square shapes only)

  • unchecked Draw effects to add advanced paintEffects paint effects for improving text readability, eg through outer glows and blurs.


図 12.18 Text settings - Shadow tab

To add a shadow to the text, enable the labelshadow Shadow tab and activate the checkbox Draw drop shadow. Then you can:

  • Indicate the item used to generate the shadow with Draw under. It can be the Lowest label component or a particular component such as the Text itself, the Buffer or the Background.

  • Set the shadow's Offset from the item being shadowded, ie:

    • The angle: clockwise, it depends on the underlying item orientation

    • The distance of offset from the item being shadowded

    • The units of the offset

    If you tick the checkbox Use global shadow checkbox, then the zero point of the angle is always oriented to the north and doesn't depend on the orientation of the label's item.

  • Influence the appearance of the shadow with the Blur radius. The higher the number, the softer the shadows, in the units of your choice.

  • Define the shadow's Opacity

  • Rescale the shadow's size using the Scale factor

  • Choose the shadow's Color

  • Use the Blend mode option to determine how your label's shadow will mix with the map components below them (more details at 描画モード).

12.3.2. 引出し線付きラベル

A common practice when placing labels on a crowded map is to use callouts - labels which are placed outside (or displaced from) their associated feature are identified with a dynamic line connecting the label and the feature. If one of the two endings (either the label or the feature) is moved, the shape of the connector is recomputed.


図 12.19 Labels with various callouts settings

To add a callout to a label, enable the labelcallout Callouts tab and activate the checkbox Draw callouts. Then you can:

  1. Select the Style of connector, one of:

    • Simple lines: a straight line, the shortest path

    • Manhattan style: a 90° broken line

  2. Select the Line style with full capabilities of a line symbol including layer effects, and data-defined settings

  3. Set the Minimum length of callout lines

  4. Set the Offset from feature option: controls the distance from the feature (or its anchor point if a polygon) where callout lines end. Eg, this avoids drawing lines right up against the edges of the features.

  5. Set the Offset from label area option: controls the distance from the label closest corner where callout lines end. This avoids drawing lines right up against the text.

  6. checkbox Draw lines to all features parts from the feature's label

  7. Set an Anchor point on the (polygon) feature to use as end point of the connector line : available options are:

    • Pole of inaccessibility

    • Point on exterior

    • Point on surface

    • Centroid

12.3.3. 配置

Choose the labelplacement Placement tab for configuring label placement and labeling priority. Note that the placement options differ according to the type of vector layer, namely point, line or polygon, and are affected by the global PAL setting. Placement for point layers

With the radioButtonOn Cartographic placement mode, point labels are generated with a better visual relationship with the point feature, following ideal cartographic placement rules. Labels can be placed at a set Distance either from the point feature itself or from the bounds of the symbol used to represent the feature. The latter option is especially useful when the symbol size isn't fixed, e.g. if it's set by a data defined size or when using different symbols in a categorized renderer.

By default, placements are prioritised in the following order:

  1. top right

  2. top left

  3. bottom right

  4. bottom left

  5. middle right

  6. middle left

  7. top, slightly right

  8. bottom, slightly left.

Placement priority can, however, be customized or set for an individual feature using a data defined list of prioritised positions. This also allows only certain placements to be used, so e.g. for coastal features you can prevent labels being placed over the land.

The radioButtonOn Around point setting places the label in an equal radius (set in Distance) circle around the feature. The placement of the label can even be constrained using the Quadrant option.

With the radioButtonOn Offset from point, labels are placed at a fixed offset from the point feature. You can select the Quadrant in which to place your label. You are also able to set the Offset X,Y distances between the points and their labels and can alter the angle of the label placement with the Rotation setting. Thus, placement in a selected quadrant with a defined rotation is possible. Placement for line layers

Label options for line layers include radioButtonOn Parallel, radioButtonOff Curved or radioButtonOff Horizontal. For the radioButtonOn Parallel and radioButtonOff Curved options, you can set the position to checkbox Above line, checkbox On line and checkbox Below line. It's possible to select several options at once. In that case, QGIS will look for the optimal label position. For Parallel and curved placement options, you can also use the line orientation for the position of the label. Additionally, you can define a Maximum angle between curved characters when selecting the radioButtonOff Curved option (see Figure_labels_placement_line).


図 12.20 Label placement examples in lines

For all three placement options, in Repeat, you can set up a minimum distance for repeating labels. The distance can be in mm or in map units. Placement for polygon layers

You can choose one of the following options for placing labels in polygons (see figure_labels_placement_polygon):

  • radioButtonOn Offset from centroid,

  • radioButtonOff Horizontal (slow),

  • radioButtonOff Around centroid,

  • radioButtonOff Free (slow),

  • radioButtonOff Using perimeter,

  • and radioButtonOff Using perimeter (curved).

In the Offset from centroid settings you can specify if the centroid is of the radioButtonOn visible polygon or radioButtonOff whole polygon. That means that either the centroid is used for the polygon you can see on the map or the centroid is determined for the whole polygon, no matter if you can see the whole feature on the map. You can place your label within a specific quadrant, and define offset and rotation.

The Around centroid setting places the label at a specified distance around the centroid. Again, you can define radioButtonOn visible polygon or radioButtonOff whole polygon for the centroid.

With the Horizontal (slow) or Free (slow) options, QGIS places at the best position either a horizontal or a rotated label inside the polygon.

With the Using perimeter option, the label will be drawn next to the polygon boundary. The label will behave like the parallel option for lines. You can define a position and a distance for the label. For the position, checkbox Above line, checkbox On line, checkbox Below line and checkbox Line orientation dependent position are possible. You can specify the distance between the label and the polygon outline, as well as the repeat interval for the label.

The Using perimeter (curved) option helps you draw the label along the polygon boundary, using a curved labeling. In addition to the parameters available with Using perimeter setting, you can set the Maximum angle between curved characters polygon, either inside or outside.


図 12.21 Label placement examples in polygons

In the priority section you can define the priority with which labels are rendered for all three vector layer types (point, line, polygon). This placement option interacts with the labels from other vector layers in the map canvas. If there are labels from different layers in the same location, the label with the higher priority will be displayed and the others will be left out.

12.3.4. 描画

In the render Rendering tab, you can tune when the labels can be rendered and their interaction with other labels and features. Label options

Under Label options:

  • You find the scale-based and the Pixel size-based visibility settings.

  • The Label z-index determines the order in which labels are rendered, as well in relation with other feature labels in the layer (using data-defined override expression), as with labels from other layers. Labels with a higher z-index are rendered on top of labels (from any layer) with lower z-index.

    Additionally, the logic has been tweaked so that if two labels have matching z-indexes, then:

    • if they are from the same layer, the smaller label will be drawn above the larger label

    • if they are from different layers, the labels will be drawn in the same order as their layers themselves (ie respecting the order set in the map legend).


    This setting doesn't make labels to be drawn below the features from other layers, it just controls the order in which labels are drawn on top of all the layers' features.

  • While rendering labels and in order to display readable labels, QGIS automatically evaluates the position of the labels and can hide some of them in case of collision. You can however choose to checkbox Show all labels for this layer (including colliding labels) in order to manually fix their placement (see ラベルツールバー).

  • With data-defined expressions in Show label and Always Show you can fine tune which labels should be rendered.

  • Allow to Show upside-down labels: alternatives are Never, when rotation defined or always. Feature options

Under Feature options:

  • You can choose to label every part of a multi-part feature and limit the number of features to be labeled.

  • Both line and polygon layers offer the option to set a minimum size for the features to be labeled, using Suppress labeling of features smaller than.

  • For polygon features, you can also filter the labels to show according to whether they completely fit within their feature or not.

  • For line features, you can choose to Merge connected lines to avoid duplicate labels, rendering a quite airy map in conjunction with the Distance or Repeat options in the Placement tab. Obstacles

An obstacle is a feature QGIS tries as far as possible to not place labels over. From the Obstacles frame, you can manage the covering relation between labels and features:

  • Activate the checkbox Discourage labels from covering features option to decide whether features of the layer should act as obstacles for any label (including labels from other features in the same layer).

    Instead of the whole layer, you can define a subset of features to use as obstacles, using the dataDefined data-defined override control next to the option.

  • The slider priority control slider for obstacles allows you to make labels prefer to overlap features from certain layers rather than others. A Low weight obstacle priority means that features of the layer are less considered as obstacles and thus more likely to be covered by labels. This priority can also be data-defined, so that within the same layer, certain features are more likely to be covered than others.

  • For polygon layers, you can choose the type of obstacle the features could be, by minimising the labels placement:

    • over the feature's interior: avoids placing labels over the interior of the polygon (prefers placing labels totally outside or just slightly inside the polygon)

    • or over the feature's boundary: avoids placing labels over boundary of the polygon (prefers placing labels outside or completely inside the polygon). E.g., it can be useful for regional boundary layers, where the features cover an entire area. In this case, it's impossible to avoid placing labels within these features, and it looks much better to avoid placing them over the boundaries between features.