In this work, we designed algorithms for the point in polygon problem based on the ray casting algorithm using equations from vector geometry. The algorithms were implemented using the python programming language. We tested the algorithm against the point in polygon algorithms used by the shapely (and by extension geopandas) library and the OpenCV library using points from the google Open Buildings project. Our algorithm in pure python performed much better than the shapely implementation. It also performed better than the OpenCV implementation when combined with the Numba optimization library. We also performed simulations to verify that our algorithm performance was of the order O(n).
翻译:本研究基于射线投射算法,利用向量几何方程设计了解决点在多边形内问题的算法。这些算法采用Python编程语言实现。我们使用谷歌开放建筑项目中的点位数据,将算法与shapely(及其扩展geopandas)库和OpenCV库中的点在多边形内算法进行了对比测试。我们的纯Python算法性能远优于shapely实现。当与Numba优化库结合使用时,其性能也优于OpenCV实现。此外,我们通过模拟实验验证了算法复杂度为O(n)量级。