Hi! Does matplotlib have already implemented a method to return true/false according as a provided point is inside a provided polygon? Thanks!

DG

Hi! Does matplotlib have already implemented a method to return true/false according as a provided point is inside a provided polygon? Thanks!

DG

In [15]: help matplotlib.nxutils

-------> help(matplotlib.nxutils)

Help on module matplotlib.nxutils in matplotlib:

NAME

matplotlib.nxutils - general purpose utilities (numpy).

FILE

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-package

s/matplotlib/nxutils.so

FUNCTIONS

pnpoly(...)

inside = pnpoly(x, y, xyverts)

return 1 if x,y is inside the polygon defined by the sequence of x,y ver

tices in xyverts

points_inside_poly(...)

mask = points_inside_poly(xypoints, xyverts)

return a mask of length xypoints indicating whether each x,y point is in

side the polygon defined by the sequence of x,y vertices in xyverts

If you're interested in the algorithm:

http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

Regards,

David

On 26-Jun-08, at 11:37 PM, David Goldsmith wrote:

Hi! Does matplotlib have already implemented a method to return true/false according as a provided point is inside a provided polygon? Thanks!

Excellent, thanks! Just reinforces my belief that in Python, if you need to do something, chances are the Python tool for it already exists in the Public Domain! I love Python!

DG

--- On Thu, 6/26/08, David Warde-Farley <dwf@...386...> wrote:

From: David Warde-Farley <dwf@...386...>

Subject: Re: [Matplotlib-users] matplotlib have "point in a polygon" test?

To: d_l_goldsmith@...9...

Cc: matplotlib-users@lists.sourceforge.net

Date: Thursday, June 26, 2008, 8:46 PM

On 26-Jun-08, at 11:37 PM, David Goldsmith wrote:> Hi! Does matplotlib have already implemented a method

to return

> true/false according as a provided point is inside a

provided

> polygon? Thanks!In [15]: help matplotlib.nxutils

-------> help(matplotlib.nxutils)

Help on module matplotlib.nxutils in matplotlib:NAME

matplotlib.nxutils - general purpose utilities

(numpy).FILE

/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-package

s/matplotlib/nxutils.soFUNCTIONS

pnpoly(...)

inside = pnpoly(x, y, xyverts)

return 1 if x,y is inside the polygon defined by

the sequence

of x,y ver

tices in xyvertspoints_inside_poly(...)

mask = points_inside_poly(xypoints, xyverts)

return a mask of length xypoints indicating

whether each x,y

point is in

side the polygon defined by the sequence of x,y vertices in

xyvertsIf you're interested in the algorithm:

http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.htmlRegards,

David