[SciPy-user] efficient "inside polygon" test for an array??

Eric Emsellem emsellem@obs.univ-lyon1...
Mon Feb 4 09:56:45 CST 2008


Hi

I have a polygon (defined by 4 vertices) and I wish to have an efficient way of
selecting the points which are inside this polygon.
So I would like something like:

selection = pointsInPolygon(x,y,poly)

where x and y are numpy arrays and poly the 2xN array defining the vertices of
the polygons.

I have the code for single points. But "vectorizing" it make this routine VERY
slow and not exploitable (I have to do this for MANY polygons and x,y arrays
which are big).

Do you have something like that in scipy (or somewhere else)?

thanks in advance!
Eric


More information about the SciPy-user mailing list