# How to surround a Polygon object with a corridor of specified width?

I'd like to build a corridor surrounding a polygon, so that the corridor's outer bounds all have the same distance to the inner bounds. Like this:

I've made this lousy graphic in Paint, since I don't even know how this operation is called. I hope you get the idea. To avoid confusion and misplaced suggestions: the outer polygon is NOT a scaled version of the inner. I know I need some transformation for this, I just don't know what kind of.

I'm implementing it in Python, I thought of shapely library, but I'm not sure if that's the one to do it, less so which method might be useful. Thanks in advance

The operation your looking for is called buffering, and is a standard function available in most GIS libraries.

In PostGIS/SpatiaLite it's called ST_Buffer(geometry g1, float radius_of_buffer);

In shapely it's called buffer. An example from the shapely docs:

``````>>> from shapely.geometry import LinearRing, Polygon
>>> coords = [(0, 0), (1, 1), (1, 0)]
>>> r = LinearRing(coords)
>>> s = Polygon(r)
>>> s.area
0.5
>>> t = Polygon(s.buffer(1.0).exterior, [r])
>>> t.area
6.5507620529190334
``````

OpenGeo has some great examples of using ST_Buffer

• AWESOME answer, thank you! Precisely what I wanted ;) Commented May 26, 2014 at 14:35

For users looking for a non-programmatic answer:

You could use QGIS, buffer your polygon and then use difference.