[QGIS-Developer] timzonefinder vs point in polygon

C Hamilton adenaculture at gmail.com
Fri Feb 5 13:22:56 PST 2021


I need the ability to do a fast time zone lookup in QGIS and found the
popular timezonefinder library which I encorported into the Date/Time Tools
plugin. See

https://github.com/NationalSecurityAgency/qgis-datetimetools-plugin/releases/tag/3.0.1

Rather than using this, Nyall suggested that I just use the original
polygon data set and do a point in polygon lookup. So I have done some
testing on a 10,000 random point data set where I was looking up the
timezone of each point.

Time results for 10,000 points
Using timezonefinder: 44 seconds

Using the algorithm Vector->Geoprocessing Tools->Intersection: 4 minutes, 4
seconds

I also tried iterating over each of the 10,000 points then testing each of
the time zone polygons to see if the point feature was contained in it
using this statement. It returned once it found a match.

polyfeature.geometry().contains(point_feature)

This was definitely not the way to do it and I killed qgis before it
finished.

My conclusion is that timezonefinder has been optimized for very fast
lookups. I'm sure there is probably a better way for me to work with a
point in polygon lookup and if anyone has any further suggestions let me
know. I can see games I could play such as first testing the bounding box
or setting up lookup tables, but that is what timezonefinder does so for
now that is what I will use.

If I have missed some fast point in polygon lookup up in the QGIS API
please let me know.

Thanks,

Calvin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210205/53c2c77e/attachment.html>


More information about the QGIS-Developer mailing list