Outdated version of the documentation. Find the latest one here.

4.2. Lesson: Instrumentul Etichetă

Labels can be added to a map to show any information about an object. Any vector layer can have labels associated with it. These labels rely on the attribute data of a layer for their content.

Note

The Layer Properties dialog does have a Labels tab, which now offers the same functionality, but for this example we’ll use the Label tool, accessed via a toolbar button.

Scopul acestei lecții: De a aplica etichete folositoare și plăcute unui strat.

4.2.1. basic Follow Along: Folosirea Etichetelor

Înainte de a putea accesa instrumentul Etichetă, va trebui să vă asigurați că acesta a fost activat.

  • Mergeți la elementul de meniu View ‣ Toolbars.

  • Asigurați-vă că elementul Label are o bifă alături. În caz contrar, faceți clic pe elementul Label pentru a-l activa.

  • Clic pe stratul places din Lista straturilor, astfel încât acesta să fie evidențiat.

  • Click on the following toolbar button: mActionLabeling

Acesta va deschide dialogul Setărilor pentru etichetarea stratului.

  • Clic pe caseta Label this layer with....

You’ll need to choose which field in the attributes will be used for the labels. In the previous lesson, you decided that the NAME field was the most suitable one for this purpose.

  • Selectați numele din listă:

../../../_images/select_label_with.png
  • Clic pe OK

Etichetele hărții ar trebui să arate astfel:

../../../_images/first_place_names.png

4.2.2. basic Follow Along: Opțiunile de Schimbare a Etichetelor

În funcție de stilurile alese pentru harta dvs. din lecțiile anterioare, e posibil să descoperiți că etichetele nu sunt formatate corespunzător și, fie se suprapun, fie nu sunt prea departe de simbolurile lor de tip punct.

  • Deschideți din nou Instrumentul de Etichetare, făcând clic pe butonul său, ca și mai înainte.

  • Make sure Text is selected in the left-hand options list, then update the text formatting options to match those shown here:
../../../_images/label_formatting_options.png

That’s the font problem solved! Now let’s look at the problem of the labels overlapping the points, but before we do that, let’s take a look at the Buffer option.

  • Deschideți dialogul Instrumentului etichetă.

  • Selectați Tamponul din lista opțiunilor enumerate în stânga.

  • Select the checkbox next to Draw text buffer, then choose options to match those shown here:
../../../_images/buffer_options.png
  • Clic pe Aplicare.

You’ll see that this adds a colored buffer or border to the place labels, making them easier to pick out on the map:

../../../_images/buffer_results.png

Now we can address the positioning of the labels in relation to their point markers.

  • In the Label tool dialog, go to the Placement tab.
  • Change the value of Distance to 2mm and make sure that Around point is selected:
../../../_images/offset_placement_settings.png
  • Clic pe Aplicare.

You’ll see that the labels are no longer overlapping their point markers.

4.2.3. moderate Follow Along: Using Labels Instead of Layer Symbology

In many cases, the location of a point doesn’t need to be very specific. For example, most of the points in the places layer refer to entire towns or suburbs, and the specific point associated with such features is not that specific on a large scale. In fact, giving a point that is too specific is often confusing for someone reading a map.

To name an example: on a map of the world, the point given for the European Union may be somewhere in Poland, for instance. To someone reading the map, seeing a point labeled European Union in Poland, it may seem that the capital of the European Union is therefore in Poland.

So, to prevent this kind of misunderstanding, it’s often useful to deactivate the point symbols and replace them completely with labels.

In QGIS, you can do this by changing the position of the labels to be rendered directly over the points they refer to.

  • Open the Layer labeling settings dialog for the places layer.
  • Select the Placement option from the options list.
  • Click on the Offset from point button.

This will reveal the Quadrant options which you can use to set the position of the label in relation to the point marker. In this case, we want the label to be centered on the point, so choose the center quadrant:

../../../_images/quadrant_offset_options.png
  • Hide the point symbols by editing the layer style as usual, and setting the size of the Ellipse marker width and height to 0:
../../../_images/hide_point_marker.png
  • Click OK and you’ll see this result:
../../../_images/hide_point_marker_results.png

If you were to zoom out on the map, you would see that some of the labels disappear at larger scales to avoid overlapping. Sometimes this is what you want when dealing with datasets that have many points, but at other times you will lose useful information this way. There is another possibility for handling cases like this, which we’ll cover in a later exercise in this lesson.

4.2.4. moderate Try Yourself Personalizarea Etichetelor

  • Return the label and symbol settings to have a point marker and a label offset of 2.00mm. You may like to adjust the styling of the point marker or labels at this stage.

Verificați-vă rezultatele

  • Set the map to the scale 1:100000. You can do this by typing it into the Scale box in the Status Bar.
  • Modificați etichetele, pentru a se potrivi vizualizării la această scară.

Verificați-vă rezultatele

4.2.5. moderate Follow Along: Etichetarea Liniilor

Now that you know how labeling works, there’s an additional problem. Points and polygons are easy to label, but what about lines? If you label them the same way as the points, your results would look like this:

../../../_images/bad_street_labels.png

Vom reformata acum etichetarea stratului roads, astfel încât acestea să fie ușor de înțeles.

  • Ascundeți stratul Places, astfel încât el să nu vă deranjeze.

  • Activați etichetele din stratul streets, ca și mai înainte.

  • Setați Mărimea fontului la 10 astfel încât să puteți vedea mai multe etichete.

  • Focalizați în aria orașului Swellendam.

  • In the Label tool dialog’s Advanced tab, choose the following settings:
../../../_images/street_label_settings.png

You’ll probably find that the text styling has used default values and the labels are consequently very hard to read. Set the label text format to have a dark-grey or black Color and a light-yellow buffer.

Harta va arăta aproximativ în modul următor, în funcție de scară:

../../../_images/street_label_formatted.png

You’ll see that some of the road names appear more than once and that’s not always necessary. To prevent this from happening:

  • In the Label labelling settings dialog, choose the Rendering option and select the Merge connected lines to avoid duplicate labels:
../../../_images/merge_lines_option.png
  • Clic pe OK

Another useful function is to prevent labels being drawn for features too short to be of notice.

  • In the same Rendering panel, set the value of Suppress labeling of features smaller than ... to 5mm and note the results when you click Apply.

Try out different Placement settings as well. As we’ve seen before, the horizontal option is not a good idea in this case, so let’s try the curved option instead.

  • Select the Curved option in the Placement panel of the Layer labeling settings dialog.

Iată rezultatul:

../../../_images/final_street_labels.png

As you can see, this hides a lot of the labels that were previously visible, because of the difficulty of making some of them follow twisting street lines and still be legible. You can decide which of these options to use, depending on what you think seems more useful or what looks better.

4.2.6. hard Follow Along: Setărilor Definite cu ajutorul Datelor

  • Dezactivați etichetele stratului Streets.

  • Rezactivați etichetele stratului Places.

  • Deschideți tabela de atribute a stratului Places, prin intermediul butonului attributes.

It has one fields which is of interest to us now: place which defines the type of urban area for each object. We can use this data to influence the label styles.

  • Navigate to the Text panel in the places Labels panel.
  • In the Italic dropdown, select Edit... to open the Expression string builder:
../../../_images/expression_string_builder.png

In the text input, type: "place"  =  'town' and click Ok twice:

../../../_images/expression_builder_settings.png

Observați-i efectele:

../../../_images/italic_label_result.png

4.2.7. hard Try Yourself Utilizarea Setărilor Definite cu ajutorul Datelor

Note

We’re jumping ahead a bit here to demonstrate some advanced labeling settings. At the advanced level, it’s assumed that you’ll know what the following means. If you don’t, feel free to leave out this section and come back later when you’ve covered the requisite materials.

  • Deschideți Tabela de Atribute a stratului places.

  • Intrați în modul de editare făcând clic pe acest buton: edit

  • Adăugați o nouă coloană:

../../../_images/add_column_button.png
  • Configurați-l astfel:

../../../_images/font_size_column.png
  • Use this to set custom font sizes for each different type of place (i.e., each key in the PLACE field).

Verificați-vă rezultatele

4.2.8. hard Alte Posibilități de Etichetare

We can’t cover every option in this course, but be aware that the Label tool has many other useful functions. You can set scale-based rendering, alter the rendering priority for labels in a layer, and set every label option using layer attributes. You can even set the rotation, XY position, and other properties of a label (if you have attribute fields allocated for the purpose), then edit these properties using the tools adjacent to the main Label tool:

mActionLabeling mActionShowPinnedLabels mActionPinLabels mActionShowHideLabels mActionMoveLabel mActionRotateLabel mActionChangeLabelProperties

(Aceste instrumente vor fi active dacă există câmpurile de atribute obligatorii și vă aflați în modul de editare.)

Simțiți-vă liberi să explorați mai multe posibilități ale sistemului de etichetare.

4.2.9. In Conclusion

Ați învățat cum să folosiți atributele stratului, pentru a crea în mod dinamic etichetele. Acest lucru poate face harta mult mai informativă și mai elegantă!

4.2.10. What’s Next?

Now that you know how attributes can make a visual difference for your map, how about using them to change the symbology of objects themselves? That’s the topic for the next lesson!