# [SciPy-User] Points with given distance to a polygon

Joe Kington jkington@wisc....
Mon Jul 26 14:28:06 CDT 2010

```On Mon, Jul 26, 2010 at 1:26 PM, Zachary Pincus <zachary.pincus@yale.edu>wrote:

> > I am working on a project where I am defining some regions of
> > interest.
> > I have a 2200x2200 px 2D Array in which my ROI is defined by a
> > polygon.
> > However, my data are smoothed by a gaussian kernel of width 300px,
> > and I
> > would like to draw some lines indicating this inner 150px distance to
> > the borders of the ROI. I cannot come up with any way to do this, does
> > anyone have an idea?
>
> Two broad options spring to mind:
> (1) Geometric -- shrink the polygon along the normals to the vertices.
> [Oh, I see that eat has given pseudocode for same... good]
> (2) Gridded -- rasterize the polygon to a binary mask (no tools for
> this in scipy, I fear... but if you're handy with opengl or something,
> that's not too hard), and then use scipy.ndimage to erode or dilate
>
> Zach
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>

If you go with a purely geometric method, look into a module like
shapely<http://trac.gispython.org/lab/wiki/Shapely>to buffer the
polygon. (similar to the code snipped eat posted, but more
flexible)

See this example<http://gispython.org/shapely/docs/1.2/manual.html#object.buffer>for
a general idea.

-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20100726/72aeb2e3/attachment.html
```