Polygon containment test


#1

Hi!

I got a list of points and a list of polygons and would like to get which point is inside which polygon. I am using Polygon.ContainmentTest (two flat lists going in and lacing set to Cross Product) and it is doing its job as long as the number of points and polygons are very low, but as soon as I start to bump those up it takes a very long time. I need to test approx 500 points and 150 polygons.

Does anyone have any ideas on why it gets so sluggish, and how I could get around it?

Thanks,

Petra

 


#2

I’ve had similar experience with that node - it’s incredibly slow! In my experience it’s faster to just patch the polygons into a surface and test them for intersections with the points with the “Geometry.DoesIntersect” node:

2015-10-07_22-47-13

This example compares 528 elements ( 278k tests) and if I try it with the containment test fails because I run out of ram! If you want to shave off a few more seconds and if your layout and geometry permits it, you could try extracting the geometry’s bounding box and testing that with the points through the “BB.Contains” node:

2015-10-07_23-02-05