Is it possible de create a custom line style in QGIS, as mentioned in the attached file?
Probably the most straight forward way to achieved that is with Labels (in Layer Properties) on top of a simple line symbol:
- activate labeling for that layer and choose the field to be used as labels
- set font size in Text tab
- in Background tab, check Draw Background and
- set Shape to
- set Size Type to
- set Size X to your liking
- set Fill Color to your map canvas' background color
- set Shape to
- in Placement tab
On linefor Allowed positions
- set Repeat to your liking
These are the minimal settings to get a similar style as in your picture. What happens here is simple: the value of the chosen field will be placed above a colored rectangle at the desired interval, overlaying the line symbol.
You should play around with the multitude of settings in the Labels tab, try to get familiar with the possibilities. The placement settings get more complicated when labels of different lines overlap etc.
One note to units: using scale sensitive units (e.g. Map Units, Meter at Scale) rather than absolute (e.g. mm) will ensure a fixed size over all scales (e.g. labels get smaller when you zoom out); might be want you want.
You have right. When the length feature is short, the label buffer hides the line and the componants of other layers. Jun 8, 2018 at 16:26
1@ennine yep. one easy way could be to only allow labels on lines with a certain length; you´d need to find an acceptable threshold, switch to Rule Based Labeling, set up a new rule (your settings should be copied) and type
$length > your_valuein the Filter field. there are other, data driven options, but at some point you will enter the realm of Cartographic Generalization, and that is a meticulous profession, done by hand... btw., QGIS 3.x comes with a very handy label moving tool– geozelotJun 8, 2018 at 17:06
Very interesting suggestion "Rule Based Labeling" which seems a good solution for short lines. Many thanks Jun 8, 2018 at 17:20
@ennine also, if you only want the line to disappear (because you only have lines on e.g. white background), you could assign a negative value to Size Y of the label's background, making it only slighty bigger than the line width (careful with bends, though, you need to adjust accordingly); that way you might be able to avoid the label's background covering other components (it might only be possible with
Fixedas Shape, not sure right now).– geozelotJun 8, 2018 at 17:36
In my case, the rule based on length resolves all my issues. My best thanks Jun 8, 2018 at 18:24