4

I have a number of bus routes, which for certain parts of their length share the exact same geometry and therefore appear as only a single line. Can I style those parts or segments of the lines that overlap exactly other lines?

Conceptually it is similar to the "rule-based" render for points that overlap. So, for example, a segment that shared its geometry with 3 others might have a lineweight of 3x, a segment overlapping with 2 a lineweight of 2x, a line by itself a lineweight of x.

NB: I don't want to actually offset the lines or use transparency. Nor can I fudge it — this is a city-wide dataset, so it cannot be done manually. I want to assign a variable stroke weight based on the geometry that overlaps.

  • Are you willing to edit the data? If so, it's a simple matter of explode lines, then set the line width to equaling_geom_count('Exploded'). If not, you should look into virtual layers. – csk Nov 21 '19 at 19:54
  • 1
    What software are you using? The answer is yes either way. – Cary H Nov 21 '19 at 20:02
2

A useful symbology. In QGIS, an "on the fly" solution using a stroke-width expression is likely possible, but may be too burdensome at render.

Since we generally deal with feature symbology, a basic solution involves using spatial operators like Contains on the features. With line features, when a whole feature is identical to another whole feature, they are 'contained'.

The following is a solution for this case, but with an additional step, can be extended to initial features where only part of their geometry is 'contained'.

  1. With Join Attributes by Location (Summary) in the native QGIS processing library - join the line features with the condition Contains and select the Summaries to calculate: "Count"
  2. Using the resulting "Count" attribute, in the Symbology tab, apply an expression on the Stroke width parameter with a data-defined override. You may need to scale the count value with some basic math: (2+"count")/10

In the likely case that only parts of features overlap, using this method, one could process the lines with Explode lines prior to the spatial join. This essentially carries the symbology down to the line segment level.

**Given that the spatial join involves data reduction, one downside with this approach is that useful attributes could be changed or lost thru summarizing.

Image showing overlapping features with stoke-weighted symbology in black and original features in white

| improve this answer | |
  • Immensely helpful, thanks so much! – JoRKS Feb 12 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.