QGIS – Preventing Text Labels from Overlapping Other Markers

labelingqgis

Is there a way within QGIS to prevent text labels from overlapping icons used to label a point layer?

In the example map shown below, there are two layers:

  1. Roads layer which is labeled using the new labeling engine.
  2. A point layer which uses svg icons to show highway shields.

I have other use cases for this such as preventing overlapping of rail station icons. In this example, I could simply move the point, however, in other cases, such as a subway station, that is not a workable solution.

A possible solution which I am considering would involve:

  1. Adding a column to the point layer's dbf file.
  2. Filling the added column with either Null or a space.
  3. Enabling QGIS's [new style] labeling for the added column.

Is this the way to go or is there a better method?

Sample Map

QGIS info: I am using versions 1.7.4 and a recently compiled version of 1.8 on Mac OS 10.7.4. Linux and Windows versions are also available to me.


Progress Update:
The method I described above works though two modifications to the process are required.

  1. Instead of using a space character or a Null, a non-breaking space has to be used. While testing I found, fields with Null are not rendered and fields with only a space(s) are converted to Null. (See this Wikipedia page for information on how to type a non-breaking space.)
  2. While setting the Layer Labeling Settings, on the Advanced tab, set the Placement to Over Point. Also set the Priority such that it is higher than any other labeled layers.

Depending on the size of the icon used, some experimentation may be required to get things to work as expected. Depending on the circumstance, it may be easier to use multiple characters rather than attempting to increase the font weight and/or size.

Sample Map 2

Tested with QGIS 1.7 and a recently compiled of 1.8 on Mac OS 10.7.4.

Best Answer

The best consistent solution I have so far is along the lines of what I have laid out above. Assuming a SHP file is used, the steps are:

  1. Open the dbf file either with a spreadsheet application such as LibreOffice, Excel, or the QGIS Table Manager plugin.
  2. Add a column to the table. If a data type is required, use string.
  3. Fill the cells with a non-breaking space. Once complete, save the changes. (See this Wikipedia page for information on how to type a non-breaking space.)
  4. Open the Layer Labeling Settings for the point layer. On the Advanced tab, set the Placement to Over Point and set the Priority such that it is higher than any other labeled layers.
Related Question