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

David Warde-Farley dwf@cs.toronto....
Mon Feb 4 12:44:44 CST 2008


On 4-Feb-08, at 11:15 AM, John Hunter wrote:

> On Feb 4, 2008 9:56 AM, Eric Emsellem <emsellem@obs.univ-lyon1.fr>  
> wrote:
>> 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)

It seems your problem has already been addressed, but some very good  
discussion of this problem (along with some 30-odd year old code, and  
a more recent C implementation) can be found at

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

I wouldn't be surprised if nxutils uses the same algorithm.

David


More information about the SciPy-user mailing list