4

I have an image below to help illustrate the style I'm trying to apply to my polygon. I have an idea of what I need to type in the geometry generator but can't get it to work. Something along the line of: difference(buffer($geometry,-2)

enter image description here

How do I make the hatching always appear at 45 degrees?

I've tried using a simple line marker but end up with hatching appearing outside the polygon or crossing over each other at times; see below.

enter image description here

  • I'm curious, why do you want hatching at a 45 degree angle to every edge? Is it purely aesthetic, or is there another reason? – csk Jan 24 at 18:41
5

Starting polygon:

enter image description here

Use the geometry generator to create a line that is the outside of the polygon with the area around the vertices removed.

difference( boundary( $geometry),buffer( nodes_to_points( $geometry),50))

Here's what the geometry generated line looks like with the default "simple line" style:

enter image description here

Add a symbol level with angled markers:

enter image description here

If the markers overlap, adjust the buffer distance in the geometry generator expression.

Add other symbol layers. Here's what it looks like with the "simple line" removed from the geometry generated symbol layer, and a simple fill polygon added as a bottom layer:

enter image description here enter image description here

  • Great answer!!! – ndawson Jan 24 at 18:32
2

There is two way to get close to what you're looking for.

The first one is a symbol with three layer (bottom to top):

  1. original polygon
  2. line fill
  3. negative buffer (geom generator) to mask the line inside the original polygon

this solution let you create some nice effect, for example using a gradient going to transparent to let the line fade slowly...

The second one create a donuts and is only the result of a geometry generator with a two layer symbol (simple fill below, line fill on top)

None of these solution will give you the 45° angled line relative to your polygon border, I don't know how it could be done without looking bad at the corner

I hope the following screen grab are clear enough (I use a (negative) buffer size of 100 relative to my polygon, you'll have to adjust the value to your need)

buffer($geometry,-100)

solution 11

solution 22

difference($geometry,buffer($geometry,-100))

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.