[GIS] Setting dashed stroke style when layers have features with sharing borders in QGIS

bordersqgisqgis-3symbology

Layers like municipalities, countries,… have features sharing the border of their neighbours: they share the same vertices (except for the features at the edges off course).

I have a municipality layer, which I set with a dashed stroke style. However, for adjacent features, the borders are displayed as a solid line (see picture)

enter image description here

How can I display all borders with a dashed stroke style?

Now it seems to overlap.

Best Answer

The "solid" border is actually two dashed lines. The dash patterns aren't aligned, so the dashes of each line cover the spaces of the other, creating the appearance of a solid line.

enter image description here

You can prevent the two borders from overlapping by choosing the option "Draw line only inside polygon."

enter image description here

This is the simplest method, but it has two downsides:

  • The dash patterns of shared borders are still mis-aligned.
  • The line width is cut in half around the outsides of the area, while the interior borders still appear full width.

To truly fix the issue, convert your polygons to lines.

  1. Run Polygons to lines algorithm to convert polygons to lines
  2. Run Dissolve algorithm to remove overlapping line segments.

    Note: this algorithm creates a temporary layer by default, which will be deleted when you close the project. Be sure to save the temporary layer by right clicking on the layer name and choosing the option "make permanent."

  3. Apply the same style to the dissolved lines layer as you used for the polygon borders.

enter image description here

  1. (Optional) If you want filled polygons, set the border stroke style to "No pen" for the polygon layer. Put the line layer above the polygon layer.