[geos-devel] finding intersection of LineString and large list of Polygon's

Forrest Williams forrest.williams at gmail.com
Tue Feb 28 08:12:15 PST 2017


First thought would be to use something like RTree
<https://github.com/Toblerity/rtree> to build an index on the polygons.

If you didn't want to go down the RTree route and stuck to the iterative
method, you could speed things up by "preparing
<https://docs.djangoproject.com/en/1.10/ref/contrib/gis/geos/#django.contrib.gis.geos.GEOSGeometry.prepared>"
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).


Forrest W.

On Tue, Feb 28, 2017 at 9:30 AM, TazMainiac <TazMainiac at gmail.com> wrote:

> Hi,
>
>   I'm not sure if this is the right mailing list for this or not - let me
> know if I should post somewhere else.
>
>   I'm using GEOS (3.5.0) via the Django (1.6.7) Python wrappers.  Under
> Cygwin currently but will be on Linux later.
>
>   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?
>
>   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.
>
>   I was hoping for a faster mechanism than just iterating over the
> original polygon list and calling intersect's on each.
>
>   I'm new to GEOS so please forgive me if I'm using incorrect terminology.
>
> Thanks,
> Taz
>
> _______________________________________________
> geos-devel mailing list
> geos-devel at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/geos-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geos-devel/attachments/20170228/8d2bf9ea/attachment.html>


More information about the geos-devel mailing list