# Finding all boundaries with x meters clearance

My goal is to find all possible "walls" (the parts of the initial polygon boundary) where I have at least x meters clearance.

Here is the full area I'm working with, but heres a short explanation what I'm trying to archive:

I tried to solve my problem by creating a negative buffer with x meters into a (Multi)Polygon. Here I use -1.8 meters for the buffer polygon in red.

I'm re-adding a Buffer with the same x meters. That's the area where I have essentially x meters clearance from the boundary.

and return the boundary of that pink buffer.

After that I want to intersect the new boundary of the buffer with my base boundary of the first area in picture 1. Im essential want to eliminate all boundary parts from the original area where I have not x meters clearance into the area and the parts of the buffer boundary where there is no boundary in the original area.

But there are small differences or the Intersection does not work at all (see last picture).

Is there any better way or adjustments in the buffer creation which makes this more precise or a tool to solve my problem another way?

Here’s another Area from my Polygon, where the intersection fails without any obvious reason. (Yellow is the Boundary of the buffer, Red is where the intersection worked):

Here is the picture of the right side (zoomed in), where intersect doesn't work, as there is a distance between the initial border (blue) and the new one from the negative and positive buffer (yellow):

``````intersection (
buffer (
buffer (\$geometry, -1.8,
join:='miter'),
1.81,
join:='miter'
),
boundary(\$geometry)
)
``````

With this expression I was able to come as close as possible to my needed solution, when I add a right sided buffer (an inward buffer at the calculated boundaries) of 1.8 meters, I can see that some part of the buffer overlaps out of the polygon (circles I drew) and where the boundary does not extends to its fullest potential (the square):

I'm aware this type of shape might be to complex for a solution with this method.

You can achieve that using QGIS expressions with `Geometry Generator` (for visualization only) or `Geometry by Expression` (for actual geometries). Use the expression below. It creates the intersection of the -1/+1 buffer with the boundary of the initial polygon.

For the second buffer, you can use a value slightly larger than 1 (1.0001) to be sure the buffer really covers the initial polygon boundary - but in my case, it works even with the value of 1 (see screenshot):

Red line, created by the expression:

``````intersection (
buffer (
buffer (\$geometry, -1),
1.0001
),
boundary(\$geometry)
)
``````

As you finally provided a sample file, I tried it with this one. As you still say you're not satisfied with the result, please tray a buffer with argument `join:='miter'`. Have a look at my result and tell me where exacly (which spot) does not correspond to the result you expect.

Light blue: initial polygon; dark blue: negative buffer of -2; red line: intersection of the +2.1 buffer with the boundary of the initial polygon: