[QGIS-Developer] Intersections with Qgis

Bo Victor Thomsen bo.victor.thomsen at gmail.com
Mon Apr 6 03:51:31 PDT 2020


Johannes -

The actual intersection code can contain a pre-check of bounding box 
intersection. This will probably  decrease computation time 
significantly for the check:

for i, geom_i in enumerate(geoms):
     for j, geom_j in enumerate(geoms):
         if j > i:

             # Check bounding box first...
             result = geom_i.boundingBoxIntersects(geom_j)

             if result:

                 # Bounding box intersects, check actual geometry...
                 result = geom_i.intersects(geom_j)

             # Do something with result...


-- 
Med venlig hilsen / Kind regards

Bo Victor Thomsen


Den 06-04-2020 kl. 11:36 skrev Johannes Wildermuth:
> Hello developers
> I've been currently working on a python plugin in which I have to find 
> all possible intersections on one layer. I want to improve the 
> efficiency of this task. It roughly looks like this:
> for i, geom in enumerate(geoms):
>     for j, geom in enumerate(geoms):
>         if j > i:
>             //intersections
> Is there a faster way? Perhaps with multithreading / rtree?
> Regards
> Johannes Wildermuth
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20200406/2e243875/attachment.html>


More information about the QGIS-Developer mailing list