1

In QGIS, I want to print a map to a PDF and use labels for my polygons with the following criteria:

  • Show all labels
  • The labels do not collide
  • The labels are placed as close to the centroid of the polygon as possible
  • If this would result in a collision, the labels are moved inside the polygon
  • If this still results in a collision, the labels are placed outside the polygon (as little as possible, drawing a line to the centroid)

This could be summarized as showing all labels without collision as close to the centroid as possible.

In my opinion, this is usually the only reasonable way to use labels when printing a map.

To provide a possible use case: Printing a map of Europe with labels showing the names of the countries. Most countries are large enough to place the label on the centroid. The labels of Switzerland, Austria and Liechtenstein overlap. The labels of Switzerland and Austria can be moved inside their polygons. Liechtenstein is too small to move the label inside the polygon far enough to avoid overlaps with the labels of Switzerland and Austria. Therefore, its label needs to be placed outside (e.g. inside Germany) with a line to the centroid of Liechtenstein. This example shows why the default suggestions are not an option in this case.

  • Omitting certain labels is not acceptable since every country needs to have a name on the map.
  • Using a fixed offset is not acceptable since this would result in too many country names outside of their polygon.
  • Using symbology (e.g. colors or numbers with legend) is not acceptable since this is usually not how you would like to have a map of different countries.
  • Manually arranging labels is in this example possible but is cumbersome and not acceptable for larger datasets.
3
  • You could try to use data-driven font size, based on area and circumfence of the country.
    – Erik
    Commented Jun 25 at 8:01
  • This question may help you - it switches to numbers when the polygon is too small to place the label in it. gis.stackexchange.com/q/224556/79
    – Ian Turton
    Commented Jun 25 at 9:24
  • Be aware of automatization trap: in some cases, automatization is a less good option than manual work as it gives worse results with more effort. To get 100% of your desired results, finding an automatic solution will be much more timeconsuming than doing it manually. A reasonable approach would be creating a basic automatic rule that resolves like 90% of cases and than manually move the remaining 10% of problematic cases. For high quality print maps, I guess manual "postprocessing" is still a good option to get best results.
    – Babel
    Commented Jun 25 at 12:20

0

Browse other questions tagged or ask your own question.