我正在用matplotlib和匀称测试点多边形函数。匀称和matplotlib点多边形不准确与地理定位
这里是一个map包含一个百慕大三角形多边形。
谷歌地图的点在多边形的功能清楚地示出testingPoint和testingPoint2是这是一个正确的结果多边形的内部。
如果我测试matplotlib两个点,并且很体面,只有point2通过测试。
In [1]: from matplotlib.path import Path
In [2]: p = Path([[25.774252, -80.190262], [18.466465, -66.118292], [32.321384, -64.75737]])
In [3]: p1=[27.254629577800088, -76.728515625]
In [4]: p2=[27.254629577800088, -74.928515625]
In [5]: p.contains_point(p1)
Out[5]: 0
In [6]: p.contains_point(p2)
Out[6]: 1
匀称示出了如matplotlib做了同样的结果。
In [1]: from shapely.geometry import Polygon, Point
In [2]: poly = Polygon(([25.774252, -80.190262], [18.466465, -66.118292], [32.321384, -64.75737]))
In [3]: p1=Point(27.254629577800088, -76.728515625)
In [4]: p2=Point(27.254629577800088, -74.928515625)
In [5]: poly.contains(p1)
Out[5]: False
In [6]: poly.contains(p2)
Out[6]: True
这里究竟发生了什么? Google的算法比那两个更好吗?
感谢
非常感谢这个想法,它确实解决了这个问题。顺便说一句,我发现身材比matplotlib慢得多,比如说运行1000次。 – Chung
很高兴知道,我将不得不看看Matplotlib的速度如何。 –
有没有什么办法可以用'matplotlib'来做转换呢? –