3

I would like to style a polygon layer in a way that only those borders that do touch other polygons are drawn.

In this very basic example, it would look (roughly) like this. Just that in this case I drew the lines;)

enter image description here

The idea is that I want to draw the borders between countries, but not the coastlines. The example QGIS Project can be downloaded from here.

3
  • 2
    I may be missing something but it looks to me that in your visual example you only drew borders that are shared with more than one polygon in contrast to your text request to draw only those borders that do not touch other polygons.
    – John
    Commented Oct 21, 2023 at 22:07
  • Agree with @John. Your visual example seems to show the exact opposite of your written request.
    – Ben W
    Commented Oct 22, 2023 at 0:46
  • totally true!! I took the not out of the questions! I actually would like to draw country borders, but not the coastlines. That was the intention
    – Lenn
    Commented Oct 22, 2023 at 6:12

1 Answer 1

4

Use Geometry Generator with this expression (alternatively, you could also use intersection() instead of shared_paths() function):

collect_geometries(
    array_foreach(
        overlay_intersects (@layer, boundary($geometry)),
        shared_paths (@element, boundary($geometry))
    )
)

I applied the Geometry Generator to a duplicated layer of your polygon layer: enter image description here

3
  • 1
    thank you so much! I was kinda close but would not have got it:)
    – Lenn
    Commented Oct 22, 2023 at 12:30
  • sorry, I just do have one (potentially silly) question. Why do you need the call to boundary($geometry) as an expression? And what does it exactly do in this context? Couldn't I just use $geometry?
    – Lenn
    Commented Oct 26, 2023 at 9:51
  • $geometry here is a polygon. We want lines instead. That's why I used boundary($geometry) to convert the polygons to lines, the outer boundaries.
    – Babel
    Commented Oct 26, 2023 at 10:40

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.