3

When I get rid of the stroke width and style in my contour polygons, I can see very thin one-pixel large gaps between said polygons.

How do I get rid of those thin clear lines?

enter image description here enter image description here enter image description here enter image description here

3
  • I don't fully understand how you're making the combination of labels, varying-thickness lines, and shading work, and what part of that the polygon symbology you screenshotted includes. But have you tried changing the stroke width to a specific number, and/or (going the other way) stroke style to "No pen"? Sometimes hairline lines behave weirdly.
    – Houska
    Jul 18, 2022 at 16:49
  • I've added a new screen capture to my question, in the hope that it might clarify it. The Contour Line layer is placed above the Contour Polygon layer. In the screen capture above, note that the Contour Line layer is deselected, so that we may only see what the Contour Polygon layer looks like: in this case, a series of polygons that still show a very thin bright line in between them, even though the option I selected for these is "hairline". This "bright line" (that I'd like to get rid of: that's what my question's about) is not as visible when the Contour Line layer is selected. Jul 18, 2022 at 19:22
  • Consider styling the raster DEM by fixed interval classes instead of extracting the contours as polygons. At each boundary, the internal ring of one polygon is joined with the external ring of another forming that visual discontinuity, which does not happen in the raster. Jul 21, 2022 at 17:12

1 Answer 1

2

The following is happening:

  1. As a bottom layer, you have contour polygons. These are shaded, with hairline "bright lines" between them. The shading is varied by eg the Categorized renderer.

  2. On top of those are contour lines, which are thicker and darker, and generally cover up the hairline bright lines from the polygons

  3. The contour lines have labels, which interrupt the darker contour lines, but you can see the bright hairlines from the polygon layer underneath.

An important consideration is how the polygons were generated, and whether there are any slight gaps between them.

If there definitely are no gaps, you should just be able to change the Stroke Style for the polygons to No Pen (as opposed to Solid Line at hairline, i.e. minimal but nonzero, stroke width). When you do that, the bright lines will no longer be drawn at all. Where the contour lines are not interrupted, you will see no difference, since the fatter contour lines are on top anyway. Where they are interrupted by the label, the bright lines will no longer show.

If for some reason you sometimes have the contour line layer turned off, and then do want the bright hairlines dividing the polygons to be drawn, you could make the Stroke Style of the polygon layer be a data-driven override, with an expression like

if(is_layer_visible('Contours Lines'),'no','solid')

This would choose No Pen or Solid (with the hairline width you have specified) based on whether the Contours Lines layer is visible or not.

If there are minuscule gaps between the contours (for instance by vectorizing and smoothing from a DEM), this may not work since there may be genuine slivers where there is no polygon.

In this instance, you could edit the polygons to make sure they topologically tile the ROI. That is outside the scope of this answer.

Alternatively, you can fake it by deliberately drawing very slightly thicker boundaries to cover the gaps. Set Stroke Style (back) to Solid Line, and set Stroke Color to be the data-defined override expression @symbol_color. Play around with Stroke width being either Hairline, or 1/2 of the line thickness in your Contour Line layer (which seems to cover the gaps). The trick is that the Categorized renderer will set the fill color to vary by category, but by default the symbol color is fixed. This makes it vary too and outlines each polygon in its fill colour.

Edited to reflect solution arrived at in comment thread

6
  • Thank you for the very detailed reply. You understand the situation perfectly well. However, although I did change the "Stroke style" to "No Pen" (see new bottom screen capture above), the weird brigth line is still visible in the Contour Polygon layer. The Contour Line layer is actually unimportant in this matter -- I should not even have mentioned it. The issue is that the Contour Polygons have this weird visual bug whereas the lines in between the polygons remain visible even when "No Pen" and "Zero Opacity" are selected. This remains true is the layer is exported as an SVG or PNG. Jul 20, 2022 at 13:09
  • 1
    @CyanideBaby, what's unclear to me is how you're getting the contours to have different shading in the first place. Your screenshot seems to indicate they would all be a specific solid colour with no data-defined override. What happens if you set Stroke style back to solid, but do whatever you need to make sure the Stroke Colour is set identical to the Fill Colour for each polygon?
    – Houska
    Jul 20, 2022 at 14:25
  • I've uploaded two new screen captures, which, hopefully, show all my settings, including how I get the contour polygons to have different colors: select "Categorized"; "ELEV_MIN" for "Value"; a color ramp of your choice; before hitting "Classify" at the bottom left of the color classification window. I've also followed your indications, to no avail: the think bright lines are still visible. Jul 21, 2022 at 16:19
  • 1
    Strange. Final thought: is it possible your contour polygons actually have minuscule gaps between them? Regardless, one more suggestion: put Stroke Style back to Solid Line, and set Stroke Color to be the data-defined override expression @symbol_color. Play around with Stroke width being either Hairline, or 1/2 of the line thickness in your Contour Line layer (which seems to cover the gaps). The trick is that the Categorized renderer will set the fill color to vary by category, but by default the symbol color is fixed. This makes it vary too and outlines each polygon in its fill colour.
    – Houska
    Jul 21, 2022 at 18:14
  • It worked -- see new and final screen capture. Thanks a million. Please, edit your initial answer so that I may accept it. Jul 22, 2022 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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