<div dir="ltr">First thought would be to use something like <a href="https://github.com/Toblerity/rtree" target="_blank">RTree</a> to build an index on the polygons.<div><br></div><div>If you didn't want to go down the RTree route and stuck to the iterative method, you could speed things up by "<a href="https://docs.djangoproject.com/en/1.10/ref/contrib/gis/geos/#django.contrib.gis.geos.GEOSGeometry.prepared" target="_blank">preparing</a>" the linestring (and possibly preparing the polygons as well beforehand, but not sure if you're thrashing at that point, I'd say play around with it).</div><div><br></div><div><br></div><div>Forrest W.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 28, 2017 at 9:30 AM, TazMainiac <span dir="ltr"><<a href="mailto:TazMainiac@gmail.com" target="_blank">TazMainiac@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Hi,<br><br>  I'm not sure if this is the right mailing list for this or not - let me know if I should post somewhere else.<br><br></div>  I'm using GEOS (3.5.0) via the Django (1.6.7) Python wrappers.  Under Cygwin currently but will be on Linux later.<br><br><div> 
 I have a large list  (1000's) of Polygons some of which overlap.  What 
is the most efficient way to find which polygons in the list intersect 
with a LineString?<br><br> 
 I would have thought that turning the list of Polygon's into a 
MultiPolygon, then calling MultiPolygon.intersection with the line 
segment would give me the polygon that the line segment intersected on. 
 This does work, but it just returns the line segment itself.  I'm 
trying to go the other way.<br><br>  I was hoping for a faster mechanism than just iterating over the original polygon list and calling intersect's on each.<br><br></div><div>  I'm new to GEOS so please forgive me if I'm using incorrect terminology.<br></div><div><br>Thanks,<br>Taz</div></div></div>
<br>______________________________<wbr>_________________<br>
geos-devel mailing list<br>
<a href="mailto:geos-devel@lists.osgeo.org">geos-devel@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/geos-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/geos-devel</a><br></blockquote></div><br></div>