# Geometry Generator - Line pattern fill to a buffer of x metres

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)` 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. • 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, 2019 at 18:41

Starting polygon: 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: Add a symbol level with angled markers: 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:

• Great answer!!! Jan 24, 2019 at 18:32

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)
`````` 1 2

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